docker-compose up 因不存在的容器发生冲突而失败

时间:2021-02-22 10:31:58

标签: docker docker-compose

我有一个奇怪的案例,docker-compose up 由于与容器 ID 的“冲突”而失败,根据 docker ps -a 的输出,该容器 ID 不存在。

我什至不知道如何调试它。这是我的会话:

docker ps -a

CONTAINER ID   IMAGE                         COMMAND                  CREATED      STATUS      PORTS     NAMES
2d054b76d2a0   gitlab/gitlab-runner:latest   "/usr/bin/dumb-init …"   6 days ago   Up 5 days             gitlab-runner-bootstrap

docker-compose up

Creating network "streamcontrolservice_default" with the default driver
Creating redis                ... error
Creating streamcontrolservice ... 

Creating streamcontrolservice ... done

ERROR: for redis  Cannot create container for service redis: Conflict. The container name "/redis" is already in use by container "57d5a784f5e49ec597350b8f0716ca0900c5ab40fe4e540037697ec8203497b1". You have to remove (or rename) that container to be able to reuse that name.
ERROR: Encountered errors while bringing up the project.

docker ps -a

CONTAINER ID   IMAGE                         COMMAND                  CREATED      STATUS      PORTS     NAMES
2d054b76d2a0   gitlab/gitlab-runner:latest   "/usr/bin/dumb-init …"   6 days ago   Up 5 days             gitlab-runner-bootstrap

docker-compose ps

        Name               Command        State          Ports        
----------------------------------------------------------------------
streamcontrolservice   /start-reload.sh   Up      0.0.0.0:2000->80/tcp

docker-compose top

streamcontrolservice
UID     PID    PPID    C   STIME   TTY     TIME                                                                      CMD                                                                 
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
root   22235   22218   0   11:10   ?     00:00:00   /usr/local/bin/python /usr/local/bin/uvicorn --reload --host 0.0.0.0 --port 80 --log-level info main:app                             
root   22295   22235   0   11:10   ?     00:00:00   /usr/local/bin/python -c from multiprocessing.resource_tracker import main;main(4)                                                   
root   22296   22235   1   11:10   ?     00:00:00   /usr/local/bin/python -c from multiprocessing.spawn import spawn_main; spawn_main(tracker_fd=5, pipe_handle=7) --multiprocessing-fork

docker-compose 配置

services:
  redis:
    container_name: redis
    image: redis:6.0.9-alpine
    ports:
    - published: 6379
      target: 6379
    restart: always
  streamcontrolservice:
    build:
      context: /home/myuser/streamcontrolservice
      dockerfile: Dockerfile
    command: /start-reload.sh
    container_name: streamcontrolservice
    environment:
      WEB_CONCURRENCY: '1'
    image: somerepo.com:1234/streamcontrolservice:development
    ports:
    - 0.0.0.0:2000:80/tcp
    restart: always
    volumes:
    - /home/myuser/streamcontrolservice/app:/app:rw
version: '3.8'

docker rm 57d5a784f5e49ec597350b8f0716ca0900c5ab40fe4e540037697ec8203497b1

Error: No such container: 57d5a784f5e49ec597350b8f0716ca0900c5ab40fe4e540037697ec8203497b1

我可以做些什么来进一步调查?

0 个答案:

没有答案