0

Im building a basic centos image with only some packages but Im forgotting something because finish well but not maintain the container. What Im doing bad?

docker-compose:

version: '3'
services:
  config_server:
    build: ../common/docker/ansible/.
    stdin_open: true
    volumes:
      - ../../api:/var/www/api
      - ../../server:/var/www/server
      - ../server/provision/server:/tmp/ansible
    working_dir: /tmp/ansible
    networks:
      net:
        ipv4_address: 172.28.0.10
    command: ansible-playbook playbook.yml

networks:
  net:
    driver: bridge
    ipam:
      driver: default
      config:
        - subnet: 172.28.0.0/24

Dockerfile:

FROM centos:7
RUN yum makecache && yum install -y epel-release wget
RUN yum install -y ansible

I would like to check If all tasks was well, and using:

docker logs 

I see logs from ansible script finishing well. But I don't know why not maintains container with Exited (0) error

command used is

docker-compose up -d --build 

Suggestions?

  • It exited because it finished running. There was nothing left to do. – Michael Hampton Aug 19 at 15:50
  • usually when finish with -d it maintains the container up, but which option I need to use to not finish? – deconya Aug 19 at 15:51
  • In order for the container to not exit, it must be running some process! – Michael Hampton Aug 19 at 15:52
  • so If I only would like to control logs of activity, I need to add some extra service to maintain container up, If no I need to use docker run to check state. Not exist any option to maintain container without services? – deconya Aug 19 at 16:03
  • If you just want to preserve logs, you can have them logged somewhere more persistent, such as to the systemd journal, or an external logging service. – Michael Hampton Aug 19 at 16:06
0

How @Michael Hampton says, I found a solution inside stackoverflow

https://stackoverflow.com/questions/38546755/docker-compose-keep-container-running/45450456

Basically we need to include command in docker-compose

command: tail -f /dev/null
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.