简体   繁体   中英

docker-compose ps doesnt show me my containers

Im new to docker.

I have a docker-compose.yml file like this :

version: '3.7'

services:

  nginx_sarahmaso:
    build:
      context: .
      dockerfile: ./compose/production/nginx/Dockerfile
    restart: always
    volumes:
      - staticfiles_sarahmaso:/app/static
      - mediafiles_sarahmaso:/app/media
    ports:
      - 4000:80
    depends_on:
      - web_sarahmaso
    networks:
      spa_network_sarahmaso:

  web_sarahmaso:
    build:
      context: .
      dockerfile: ./compose/production/django/Dockerfile
    restart: always
    command: /start
    volumes:
      - staticfiles_sarahmaso:/app/static
      - mediafiles_sarahmaso:/app/media
      - sqlite_sarahmaso:/app/db  
    env_file:
      - ./env/prod-sample
    networks:
      spa_network_sarahmaso:



networks:
  spa_network_sarahmaso:

volumes:
  sqlite_sarahmaso:
  staticfiles_sarahmaso:
  mediafiles_sarahmaso:

I'm deploying this on a server with a sh script running these commands :

 mkdir -p /app
    rm -rf /app/* && tar -xf /tmp/project.tar -C /app
    sudo docker-compose -f /app/docker-compose.yml build
    sudo supervisorctl restart react-wagtail-project
    sudo ufw allow port

However the supervisorctl doesnt run correctly. But the console tells me "Successfully built dc10bd26b175" after the docker build.

But when i run docker-compose ps or docker ps -ai dont see any containers. Docker-compose ps asks me for a docker-compose.yml file and if i do docker-compose ps -f path_to/docker-compose.yml the console shows me the help slug :

List containers.

Usage: ps [options] [SERVICE...]

Options:
    -q, --quiet          Only display IDs
    --services           Display services
    --filter KEY=VAL     Filter services by a property
    -a, --all            Show all stopped containers (including those created by the run command)

How come i dont see my containers?

It seems your containers are not started.

With your line sudo docker-compose -f /app/docker-compose.yml build you are building your container, as the console message tells you.

I do not exactly know what this line does sudo supervisorctl restart react-wagtail-project , but to me, it does not look like a command to START your newly built containers.

Try to explicitely start your containers by adding
./path_to_compose/docker-compose up or
./path_to_compose/docker-compose up -d to your script.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM