docker 其它说明
参数的作用顺序: 说明:在构造容器时,Dcokerfile文件有有CMD项,前台运行(daemon off;)还是后台运行(daemon on;); [root@localhost7B alpine]# docker run -d -it -p 80:80 alpine_ningx:test [root@localhost7B alpine]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 06090a5ab3e2 alpine_ningx:test "nginx -g 'daemon of…" About a minute ago Up About a minute 0.0.0.0:80->80/tcp, :::80->80/tcp, 443/tcp infallible_swanson [root@localhost7B alpine]# docker run -d -it -p 80:80 alpine_ningx:test 说明:容器没有运行, COMMAND 显示为sh,覆盖了"nginx -g 'daemon of…" [root@localhost7B ubuntu]# docker run -d -it -p 80:80 alpine_ningx:test sh [root@localhost7B alpine]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES [root@localhost7B alpine]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES f6b4be689e06 alpine_ningx:test "nginx sh" 9 seconds ago Exited (1) 7 seconds ago intelligent_bouman
正确的启动方式
docker run -d -it -p 80:80 --name nginx alpine_ningx:test docker exec -it nginx sh docker stop/start nginx
cat /etc/docker/daemon.json { "bip": "172.30.0.1/24", #修改bridge网段 "storage-driver": "overlay2", #设置存储引擎类型 "registry-mirrors": ["https://si7y70hh.mirror.aliyuncs.com"], #设置docker 镜像加速器地址 "dns" : [ "114.114.114.114", "119.29.29.29"] #设置容器DNS地址,用--dns参数优先级更高 }
修改bridge模式默认的网段方法1 [root@localhost7C ~]# cat /lib/systemd/system/docker.service [Unit] Description=Docker Application Container Engine Documentation=http://docs.docker.com After=network.target Wants=docker-storage-setup.service Requires=docker-cleanup.timer [Service] Type=notify NotifyAccess=main EnvironmentFile=-/run/containers/registries.conf EnvironmentFile=-/etc/sysconfig/docker EnvironmentFile=-/etc/sysconfig/docker-storage EnvironmentFile=-/etc/sysconfig/docker-network Environment=GOTRACEBACK=crash Environment=DOCKER_HTTP_HOST_COMPAT=1 Environment=PATH=/usr/libexec/docker:/usr/bin:/usr/sbin ExecStart=/usr/bin/dockerd-current \ --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current \ --default-runtime=docker-runc \ --exec-opt native.cgroupdriver=systemd \ --userland-proxy-path=/usr/libexec/docker/docker-proxy-current \ --init-path=/usr/libexec/docker/docker-init-current \ --seccomp-profile=/etc/docker/seccomp.json \ --bip=10.100.0.1/24 \ $OPTIONS \ $DOCKER_STORAGE_OPTIONS \ $DOCKER_NETWORK_OPTIONS \ $ADD_REGISTRY \ $BLOCK_REGISTRY \ $INSECURE_REGISTRY \ $REGISTRIES ExecReload=/bin/kill -s HUP $MAINPID LimitNOFILE=1048576 LimitNPROC=1048576 LimitCORE=infinity TimeoutStartSec=0 Restart=on-abnormal KillMode=process [Install] WantedBy=multi-user.target 修改bridge网络配置方法2 cat /etc/docker/daemon.json { "bip": "10.100.0.1/24", #修改bridge网段 "storage-driver": "overlay2", #设置存储引擎类型 "registry-mirrors": ["https://si7y70hh.mirror.aliyuncs.com"], #设置docker 镜像加速器地址 "dns" : [ "114.114.114.114", "119.29.29.29"] #设置容器DNS地址,用--dns参数优先级更高 }