升级了 docker 但重启后旧配置仍在运行

升级了 docker 但重启后旧配置仍在运行

前几天,我升级了 Ubuntu 系统上的 Docker 安装。根据我的 docker 版本命令,我的客户端版本是 19.03.8,服务器上是 18.09.9。我有原始的 docker-compose.yml 文件,它在原始设置下运行(不记得版本了)。我在新的 Compose 文件上创建了一个新配置(旧配置仍然存在)。问题是,当我尝试使用docker compose up该文件时,系统提示我已有几个端口正在使用中。执行此操作docker ps显示没有正在运行的容器,但如果我运行,systemctl status docker.service我可以看到原始 Compose 文件中的所有容器都在运行。(我将在下面粘贴它)。我该怎么做才能让这些停止,以便我的新容器/配置启动并正确运行?

   Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2020-05-04 01:01:00 UTC; 9min ago
     Docs: https://docs.docker.com
 Main PID: 1570 (dockerd)
    Tasks: 191
   CGroup: /system.slice/docker.service
           ├─1570 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
           ├─2328 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 33400 -container-ip 172.18.0.2 -container-port 33400
           ├─2342 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 32469 -container-ip 172.18.0.2 -container-port 32469
           ├─2356 /usr/bin/docker-proxy -proto udp -host-ip 0.0.0.0 -host-port 32414 -container-ip 172.18.0.2 -container-port 32414
           ├─2370 /usr/bin/docker-proxy -proto udp -host-ip 0.0.0.0 -host-port 32413 -container-ip 172.18.0.2 -container-port 32413
           ├─2393 /usr/bin/docker-proxy -proto udp -host-ip 0.0.0.0 -host-port 32412 -container-ip 172.18.0.2 -container-port 32412
           ├─2405 /usr/bin/docker-proxy -proto udp -host-ip 0.0.0.0 -host-port 32410 -container-ip 172.18.0.2 -container-port 32410
           ├─2420 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 32400 -container-ip 172.18.0.2 -container-port 32400
           ├─2434 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8324 -container-ip 172.18.0.2 -container-port 8324
           ├─2448 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 3005 -container-ip 172.18.0.2 -container-port 3005
           ├─2462 /usr/bin/docker-proxy -proto udp -host-ip 0.0.0.0 -host-port 1900 -container-ip 172.18.0.2 -container-port 1900
           ├─2476 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 4040 -container-ip 172.18.0.3 -container-port 4040
           ├─2652 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 3306 -container-ip 172.18.0.8 -container-port 3306
           ├─6226 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 9091 -container-ip 172.18.0.13 -container-port 9091
           ├─6443 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8920 -container-ip 172.18.0.13 -container-port 8920
           ├─6457 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8080 -container-ip 172.18.0.14 -container-port 8080
           ├─6473 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8096 -container-ip 172.18.0.13 -container-port 8096
           ├─6485 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 443 -container-ip 172.18.0.14 -container-port 443
           └─6498 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 80 -container-ip 172.18.0.14 -container-port 80

May 04 01:00:54 media_server dockerd[1570]: time="2020-05-04T01:00:54.642848692Z" level=warning msg="Health check for container fde7ffb770ea235d2b21e7aa5c9550783827bd539c0937a707cb
May 04 01:00:55 media_server dockerd[1570]: time="2020-05-04T01:00:55.582611517Z" level=warning msg="Security options with `:` as a separator are deprecated and will be completely
May 04 01:00:55 media_server dockerd[1570]: time="2020-05-04T01:00:55.582814909Z" level=warning msg="Security options with `:` as a separator are deprecated and will be completely
May 04 01:00:55 media_server dockerd[1570]: time="2020-05-04T01:00:55.638352716Z" level=warning msg="Security options with `:` as a separator are deprecated and will be completely
May 04 01:00:57 media_server dockerd[1570]: time="2020-05-04T01:00:57.752351831Z" level=info msg="Loading containers: done."
May 04 01:01:00 media_server dockerd[1570]: time="2020-05-04T01:01:00.370749213Z" level=info msg="Docker daemon" commit=afacb8b7f0 graphdriver(s)=overlay2 version=19.03.8
May 04 01:01:00 media_server dockerd[1570]: time="2020-05-04T01:01:00.412157436Z" level=info msg="Daemon has completed initialization"
May 04 01:01:00 media_server dockerd[1570]: time="2020-05-04T01:01:00.544504808Z" level=info msg="API listen on /var/run/docker.sock"
May 04 01:01:00 media_server systemd[1]: Started Docker Application Container Engine.
May 04 01:01:01 media_server dockerd[1570]: time="2020-05-04T01:01:01.861407238Z" level=warning msg="Health check for container fde7ffb770ea235d2b21e7aa5c9550783827bd539c0937a707cb
r ```

答案1

docker ps -a

显示已停止的容器。您必须

docker rm <container>

重新创建之前,请先检查每个文件是否已存在。或者

docker-compose down

从包含 docker-compose.yml 的目录中,使用一个命令从项目中删除所有容器

如果你重新启动现有的 Docker 容器(无论正在运行还是已停止),它们将在重新启动后恢复到该状态

相关内容