zoukankan      html  css  js  c++  java
  • 系统综合实践 第2次实践作业

    一.实现一个自定义的web容器服务
    1.获取nginx镜像

    2.查看镜像

    3.运行并查看

    4.在网页查看

    5.在用户主目录创建dockerfile目录

    6.运行nginx并查看default.conf

    7.在dockerfile目录中创建文件并将dafault.conf内容复制过来

    8.修改default.conf配置:修改端口号与路径

    9.创建简易的html文件


    10.编写Dockerfile文件

    12.在该目录下构建镜像

    13.运行并查看

    14.在网页中查看

    二.实现一个自定义的数据库容器服务
    1.在用户主目录创建mymysql文件夹,并配置文件

    (1)编写dockerfile

    (2)编写setup.sh

    (3)编写schema.sql

    (4)编写privileges.sql

    2.在该目录下创建镜像

    3.运行容器

    4.进入容器

    5.使用docker用户登录数据库

    6.切换至docker_mysql数据库

    7.查看表中数据

    8.查看容器配置信息

    [
    {
    "Id": "54dd316d7601052e1ae60de5b0db70b8369cbd9ddf57638866e18794cae993f3",
    "Created": "2020-04-23T09:28:38.597143352Z",
    "Path": "docker-entrypoint.sh",
    "Args": [
    "sh",
    "/mysql/setup.sh"
    ],
    "State": {
    "Status": "running",
    "Running": true,
    "Paused": false,
    "Restarting": false,
    "OOMKilled": false,
    "Dead": false,
    "Pid": 3998,
    "ExitCode": 0,
    "Error": "",
    "StartedAt": "2020-04-23T09:28:38.962314471Z",
    "FinishedAt": "0001-01-01T00:00:00Z"
    },
    "Image": "sha256:bc050059bd344a98b096ee8d25962ac32dc46097de39aa921a80b6d3c9ec0027",
    "ResolvConfPath": "/var/lib/docker/containers/54dd316d7601052e1ae60de5b0db70b8369cbd9ddf57638866e18794cae993f3/resolv.conf",
    "HostnamePath": "/var/lib/docker/containers/54dd316d7601052e1ae60de5b0db70b8369cbd9ddf57638866e18794cae993f3/hostname",
    "HostsPath": "/var/lib/docker/containers/54dd316d7601052e1ae60de5b0db70b8369cbd9ddf57638866e18794cae993f3/hosts",
    "LogPath": "/var/lib/docker/containers/54dd316d7601052e1ae60de5b0db70b8369cbd9ddf57638866e18794cae993f3/54dd316d7601052e1ae60de5b0db70b8369cbd9ddf57638866e18794cae993f3-json.log",
    "Name": "/hmysql",
    "RestartCount": 0,
    "Driver": "overlay2",
    "Platform": "linux",
    "MountLabel": "",
    "ProcessLabel": "",
    "AppArmorProfile": "docker-default",
    "ExecIDs": null,
    "HostConfig": {
    "Binds": null,
    "ContainerIDFile": "",
    "LogConfig": {
    "Type": "json-file",
    "Config": {}
    },
    "NetworkMode": "default",
    "PortBindings": {
    "3306/tcp": [
    {
    "HostIp": "",
    "HostPort": "13306"
    }
    ]
    },
    "RestartPolicy": {
    "Name": "no",
    "MaximumRetryCount": 0
    },
    "AutoRemove": false,
    "VolumeDriver": "",
    "VolumesFrom": null,
    "CapAdd": null,
    "CapDrop": null,
    "Capabilities": null,
    "Dns": [],
    "DnsOptions": [],
    "DnsSearch": [],
    "ExtraHosts": null,
    "GroupAdd": null,
    "IpcMode": "private",
    "Cgroup": "",
    "Links": null,
    "OomScoreAdj": 0,
    "PidMode": "",
    "Privileged": false,
    "PublishAllPorts": false,
    "ReadonlyRootfs": false,
    "SecurityOpt": null,
    "UTSMode": "",
    "UsernsMode": "",
    "ShmSize": 67108864,
    "Runtime": "runc",
    "ConsoleSize": [
    0,
    0
    ],
    "Isolation": "",
    "CpuShares": 0,
    "Memory": 0,
    "NanoCpus": 0,
    "CgroupParent": "",
    "BlkioWeight": 0,
    "BlkioWeightDevice": [],
    "BlkioDeviceReadBps": null,
    "BlkioDeviceWriteBps": null,
    "BlkioDeviceReadIOps": null,
    "BlkioDeviceWriteIOps": null,
    "CpuPeriod": 0,
    "CpuQuota": 0,
    "CpuRealtimePeriod": 0,
    "CpuRealtimeRuntime": 0,
    "CpusetCpus": "",
    "CpusetMems": "",
    "Devices": [],
    "DeviceCgroupRules": null,
    "DeviceRequests": null,
    "KernelMemory": 0,
    "KernelMemoryTCP": 0,
    "MemoryReservation": 0,
    "MemorySwap": 0,
    "MemorySwappiness": null,
    "OomKillDisable": false,
    "PidsLimit": null,
    "Ulimits": null,
    "CpuCount": 0,
    "CpuPercent": 0,
    "IOMaximumIOps": 0,
    "IOMaximumBandwidth": 0,
    "MaskedPaths": [
    "/proc/asound",
    "/proc/acpi",
    "/proc/kcore",
    "/proc/keys",
    "/proc/latency_stats",
    "/proc/timer_list",
    "/proc/timer_stats",
    "/proc/sched_debug",
    "/proc/scsi",
    "/sys/firmware"
    ],
    "ReadonlyPaths": [
    "/proc/bus",
    "/proc/fs",
    "/proc/irq",
    "/proc/sys",
    "/proc/sysrq-trigger"
    ]
    },
    "GraphDriver": {
    "Data": {
    "LowerDir": "/var/lib/docker/overlay2/e6bed09a7e68fbeb743b5dbf1c9c9949d316264f0af687c9afaba90247b21140-init/diff:/var/lib/docker/overlay2/c4e8b25196de4b04867a2f41db4d556f4b022081fa0b79ec8af3eebd2c6ab0b3/diff:/var/lib/docker/overlay2/2edace736fda511cce39c5b84816c6bdc2883454bcc792d603891145ea9ef956/diff:/var/lib/docker/overlay2/391ffd4a76d921acd2336eed9ef8e4bed757b5374e69ed36e88aa3d5888b5ba9/diff:/var/lib/docker/overlay2/24e7558d8fd7385ed0fb469191614c729f339de36d2d3773e3e9e8b52aedd8df/diff:/var/lib/docker/overlay2/a6492735af4edfcd940a6ddfee01f23aa763dc0ca4a08ddc5de52a3217f52f81/diff:/var/lib/docker/overlay2/8078498ca8a99e43de4d8ce719ee16b4b26b148c13de63d277d329288109f9a5/diff:/var/lib/docker/overlay2/25f632cdc5c1308c9e5dfccf4fd50dbab521232cd133c824b4221ed7b35548d4/diff:/var/lib/docker/overlay2/dde72627cb4edc4eb1adc9274bd81306d5c9babdcff876c398dc62bfc9edfe79/diff:/var/lib/docker/overlay2/8b67aee33a9c64871a53bbae86c9ed8b760f88ecc8de8ffc6685cb81bfed9e18/diff:/var/lib/docker/overlay2/0df53d4b386cd3bf52d18886f0a2ab7ba4f552735e1b32b4231eb377d0ddddd8/diff:/var/lib/docker/overlay2/3289606ce71477de3880dc0558d6e55c66fc3f20b54d20399d4e4abf7e1694c0/diff:/var/lib/docker/overlay2/484ddd41bf2edd5e925fbe6ac95a27576952eb2077f1e685af7a66b9aa61507a/diff:/var/lib/docker/overlay2/842fb7cf09d59e92bbf409c0ac00894a8df9e9529d6ab1e4325cd20616c3c42c/diff:/var/lib/docker/overlay2/3056680a4b98efa88a352ef0a4f0723f53b5aebd3b4b2702bd5d4a889490b6e2/diff",
    "MergedDir": "/var/lib/docker/overlay2/e6bed09a7e68fbeb743b5dbf1c9c9949d316264f0af687c9afaba90247b21140/merged",
    "UpperDir": "/var/lib/docker/overlay2/e6bed09a7e68fbeb743b5dbf1c9c9949d316264f0af687c9afaba90247b21140/diff",
    "WorkDir": "/var/lib/docker/overlay2/e6bed09a7e68fbeb743b5dbf1c9c9949d316264f0af687c9afaba90247b21140/work"
    },
    "Name": "overlay2"
    },
    "Mounts": [
    {
    "Type": "volume",
    "Name": "bae69e1fc9db964e6e8cb32dabc68548b0cc69fd15baecfb5d0c56ea16063108",
    "Source": "/var/lib/docker/volumes/bae69e1fc9db964e6e8cb32dabc68548b0cc69fd15baecfb5d0c56ea16063108/_data",
    "Destination": "/var/lib/mysql",
    "Driver": "local",
    "Mode": "",
    "RW": true,
    "Propagation": ""
    }
    ],
    "Config": {
    "Hostname": "54dd316d7601",
    "Domainname": "",
    "User": "",
    "AttachStdin": false,
    "AttachStdout": false,
    "AttachStderr": false,
    "ExposedPorts": {
    "3306/tcp": {},
    "33060/tcp": {}
    },
    "Tty": false,
    "OpenStdin": false,
    "StdinOnce": false,
    "Env": [
    "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
    "GOSU_VERSION=1.12",
    "MYSQL_MAJOR=5.7",
    "MYSQL_VERSION=5.7.29-1debian10",
    "MYSQL_ALLOW_EMPTY_PASSWORD=yes"
    ],
    "Cmd": [
    "sh",
    "/mysql/setup.sh"
    ],
    "Image": "hzmysql",
    "Volumes": {
    "/var/lib/mysql": {}
    },
    "WorkingDir": "",
    "Entrypoint": [
    "docker-entrypoint.sh"
    ],
    "OnBuild": null,
    "Labels": {}
    },
    "NetworkSettings": {
    "Bridge": "",
    "SandboxID": "329a8e4e4cae3c18e3807fa8f589dccf72dd4d73f2e5cfbc75f8cde88b684069",
    "HairpinMode": false,
    "LinkLocalIPv6Address": "",
    "LinkLocalIPv6PrefixLen": 0,
    "Ports": {
    "3306/tcp": [
    {
    "HostIp": "0.0.0.0",
    "HostPort": "13306"
    }
    ],
    "33060/tcp": null
    },
    "SandboxKey": "/var/run/docker/netns/329a8e4e4cae",
    "SecondaryIPAddresses": null,
    "SecondaryIPv6Addresses": null,
    "EndpointID": "a21697ffa66bc62b254351bc02566595f5d78765f86cbbb149084195414f7ef5",
    "Gateway": "172.17.0.1",
    "GlobalIPv6Address": "",
    "GlobalIPv6PrefixLen": 0,
    "IPAddress": "172.17.0.3",
    "IPPrefixLen": 16,
    "IPv6Gateway": "",
    "MacAddress": "02:42:ac:11:00:03",
    "Networks": {
    "bridge": {
    "IPAMConfig": null,
    "Links": null,
    "Aliases": null,
    "NetworkID": "2831045e06a57d791fa2659d092286764a3e795b2373fa79aaf3949b13723f0e",
    "EndpointID": "a21697ffa66bc62b254351bc02566595f5d78765f86cbbb149084195414f7ef5",
    "Gateway": "172.17.0.1",
    "IPAddress": "172.17.0.3",
    "IPPrefixLen": 16,
    "IPv6Gateway": "",
    "GlobalIPv6Address": "",
    "GlobalIPv6PrefixLen": 0,
    "MacAddress": "02:42:ac:11:00:03",
    "DriverOpts": null
    }
    }
    }
    }
    ]

  • 相关阅读:
    linux 网络编程比较好的文章
    linux 命令
    感冒了
    aa
    111
    仿京东(我的商城)鼠标上去弹出层效果
    仿汽车之家搜索页价格签区间(鼠标拖拽同时tip提示)
    关于DW 打不开后缀名为.ftl的文件 配置方法
    客户端与服务器段的交互 通过json
    jquery 阻止事件冒泡
  • 原文地址:https://www.cnblogs.com/silentstone/p/12762638.html
Copyright © 2011-2022 走看看