Centos docker-compose is showing exit code 0 but still it doesn’t run

It’s a simple docker-compose file, which should create a centos image up and running with exposed port 5000 and dedicated volume storage.

version: '3'

services:
  mlos:
    image: centos
    ports:
     - 50:5000
    volumes:
     - ml_stor:/root/docker-compose-files/ml/docker-storage   

volumes:
  ml_stor:

But when I run docker-compose up
it is showing exit 0.

I tried removing exposed ports 5000 and dedicated volumes also. But still, it’s the same.

If restart: always is added to docker-compose,
It is restarting after running for a couple of seconds.

Here’s the output of docker-compose --verbose up command:

compose.config.config.find: Using configuration files: ./docker-compose.yml
docker.utils.config.find_config_file: Trying paths: ['/root/.docker/config.json', '/root/.dockercfg']
docker.utils.config.find_config_file: No config file found
docker.utils.config.find_config_file: Trying paths: ['/root/.docker/config.json', '/root/.dockercfg']
docker.utils.config.find_config_file: No config file found
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.25/version HTTP/1.1" 200 860
compose.cli.command.get_client: docker-compose version 1.25.5, build 8a1c60f6
docker-py version: 4.1.0
CPython version: 3.7.5
OpenSSL version: OpenSSL 1.1.0l  10 Sep 2019
compose.cli.command.get_client: Docker base_url: http+docker://localhost
compose.cli.command.get_client: Docker version: Platform={'Name': 'Docker Engine - Community'}, Components=[{'Name': 'Engine', 'Version': '19.03.8', 'Details': {'ApiVersion': '1.40', 'Arch': 'amd64', 'BuildTime': '2020-03-11T01:25:42.000000000+00:00', 'Experimental': 'false', 'GitCommit': 'afacb8b', 'GoVersion': 'go1.12.17', 'KernelVersion': '4.18.0-80.el8.x86_64', 'MinAPIVersion': '1.12', 'Os': 'linux'}}, {'Name': 'containerd', 'Version': '1.2.13', 'Details': {'GitCommit': '7ad184331fa3e55e52b890ea95e65ba581ae3429'}}, {'Name': 'runc', 'Version': '1.0.0-rc10', 'Details': {'GitCommit': 'dc9208a3303feef5b3839f4323d9beb36df0a9dd'}}, {'Name': 'docker-init', 'Version': '0.18.0', 'Details': {'GitCommit': 'fec3683'}}], Version=19.03.8, ApiVersion=1.40, MinAPIVersion=1.12, GitCommit=afacb8b, GoVersion=go1.12.17, Os=linux, Arch=amd64, KernelVersion=4.18.0-80.el8.x86_64, BuildTime=2020-03-11T01:25:42.000000000+00:00
compose.cli.verbose_proxy.proxy_callable: docker inspect_network <- ('ml_default')
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.25/networks/ml_default HTTP/1.1" 200 552
compose.cli.verbose_proxy.proxy_callable: docker inspect_network -> {'Attachable': True,
 'ConfigFrom': {'Network': ''},
 'ConfigOnly': False,
 'Containers': {},
 'Created': '2020-05-24T11:49:02.241965325+05:30',
 'Driver': 'bridge',
 'EnableIPv6': False,
 'IPAM': {'Config': [{'Gateway': '192.168.64.1', 'Subnet': '192.168.64.0/20'}],
          'Driver': 'default',
          'Options': None},
...
compose.cli.verbose_proxy.proxy_callable: docker inspect_volume <- ('ml_ml_stor')
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.25/volumes/ml_ml_stor HTTP/1.1" 200 287
compose.cli.verbose_proxy.proxy_callable: docker inspect_volume -> {'CreatedAt': '2020-05-24T11:18:29+05:30',
 'Driver': 'local',
 'Labels': {'com.docker.compose.project': 'ml',
            'com.docker.compose.version': '1.25.5',
            'com.docker.compose.volume': 'ml_stor'},
 'Mountpoint': '/var/lib/docker/volumes/ml_ml_stor/_data',
 'Name': 'ml_ml_stor',
 'Options': None,
 'Scope': 'local'}
compose.cli.verbose_proxy.proxy_callable: docker info <- ()
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.25/info HTTP/1.1" 200 None
compose.cli.verbose_proxy.proxy_callable: docker info -> {'Architecture': 'x86_64',
 'BridgeNfIp6tables': True,
 'BridgeNfIptables': True,
 'CPUSet': True,
 'CPUShares': True,
 'CgroupDriver': 'cgroupfs',
 'ClusterAdvertise': '',
 'ClusterStore': '',
 'ContainerdCommit': {'Expected': '7ad184331fa3e55e52b890ea95e65ba581ae3429',
                      'ID': '7ad184331fa3e55e52b890ea95e65ba581ae3429'},
...
compose.cli.verbose_proxy.proxy_callable: docker inspect_network <- ('ml_default')
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.25/networks/ml_default HTTP/1.1" 200 552
compose.cli.verbose_proxy.proxy_callable: docker inspect_network -> {'Attachable': True,
 'ConfigFrom': {'Network': ''},
 'ConfigOnly': False,
 'Containers': {},
 'Created': '2020-05-24T11:49:02.241965325+05:30',
 'Driver': 'bridge',
 'EnableIPv6': False,
 'IPAM': {'Config': [{'Gateway': '192.168.64.1', 'Subnet': '192.168.64.0/20'}],
          'Driver': 'default',
          'Options': None},
...
compose.cli.verbose_proxy.proxy_callable: docker inspect_volume <- ('ml_ml_stor')
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.25/volumes/ml_ml_stor HTTP/1.1" 200 287
compose.cli.verbose_proxy.proxy_callable: docker inspect_volume -> {'CreatedAt': '2020-05-24T11:18:29+05:30',
 'Driver': 'local',
 'Labels': {'com.docker.compose.project': 'ml',
            'com.docker.compose.version': '1.25.5',
            'com.docker.compose.volume': 'ml_stor'},
 'Mountpoint': '/var/lib/docker/volumes/ml_ml_stor/_data',
 'Name': 'ml_ml_stor',
 'Options': None,
 'Scope': 'local'}
compose.cli.verbose_proxy.proxy_callable: docker inspect_volume <- ('ml_ml_stor')
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.25/volumes/ml_ml_stor HTTP/1.1" 200 287
compose.cli.verbose_proxy.proxy_callable: docker inspect_volume -> {'CreatedAt': '2020-05-24T11:18:29+05:30',
 'Driver': 'local',
 'Labels': {'com.docker.compose.project': 'ml',
            'com.docker.compose.version': '1.25.5',
            'com.docker.compose.volume': 'ml_stor'},
 'Mountpoint': '/var/lib/docker/volumes/ml_ml_stor/_data',
 'Name': 'ml_ml_stor',
 'Options': None,
 'Scope': 'local'}
compose.cli.verbose_proxy.proxy_callable: docker containers <- (all=False, filters={'label': ['com.docker.compose.project=ml', 'com.docker.compose.oneoff=False']})
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.25/containers/json?limit=-1&all=0&size=0&trunc_cmd=0&filters=%7B%22label%22%3A+%5B%22com.docker.compose.project%3Dml%22%2C+%22com.docker.compose.oneoff%3DFalse%22%5D%7D HTTP/1.1" 200 1745
compose.cli.verbose_proxy.proxy_callable: docker containers -> (list with 1 items)
compose.cli.verbose_proxy.proxy_callable: docker containers <- (all=True, filters={'label': ['com.docker.compose.project=ml', 'com.docker.compose.oneoff=False']})
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.25/containers/json?limit=-1&all=1&size=0&trunc_cmd=0&filters=%7B%22label%22%3A+%5B%22com.docker.compose.project%3Dml%22%2C+%22com.docker.compose.oneoff%3DFalse%22%5D%7D HTTP/1.1" 200 1745
compose.cli.verbose_proxy.proxy_callable: docker containers -> (list with 1 items)
compose.cli.verbose_proxy.proxy_callable: docker inspect_container <- ('18b3ca700791f4475a4fc4fc3241a910a12ffbd9d74298faf852b6f9e6fa55e9')
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.25/containers/18b3ca700791f4475a4fc4fc3241a910a12ffbd9d74298faf852b6f9e6fa55e9/json HTTP/1.1" 200 None
compose.cli.verbose_proxy.proxy_callable: docker inspect_container -> {'AppArmorProfile': '',
 'Args': [],
 'Config': {'AttachStderr': False,
            'AttachStdin': False,
            'AttachStdout': False,
            'Cmd': ['/bin/bash'],
            'Domainname': '',
            'Entrypoint': None,
            'Env': ['PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'],
            'ExposedPorts': {'5000/tcp': {}},
...
compose.cli.verbose_proxy.proxy_callable: docker containers <- (all=True, filters={'label': ['com.docker.compose.project=ml', 'com.docker.compose.service=mlos', 'com.docker.compose.oneoff=False']})
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.25/containers/json?limit=-1&all=1&size=0&trunc_cmd=0&filters=%7B%22label%22%3A+%5B%22com.docker.compose.project%3Dml%22%2C+%22com.docker.compose.service%3Dmlos%22%2C+%22com.docker.compose.oneoff%3DFalse%22%5D%7D HTTP/1.1" 200 1745
compose.cli.verbose_proxy.proxy_callable: docker containers -> (list with 1 items)
compose.cli.verbose_proxy.proxy_callable: docker inspect_container <- ('18b3ca700791f4475a4fc4fc3241a910a12ffbd9d74298faf852b6f9e6fa55e9')
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.25/containers/18b3ca700791f4475a4fc4fc3241a910a12ffbd9d74298faf852b6f9e6fa55e9/json HTTP/1.1" 200 None
compose.cli.verbose_proxy.proxy_callable: docker inspect_container -> {'AppArmorProfile': '',
 'Args': [],
 'Config': {'AttachStderr': False,
            'AttachStdin': False,
            'AttachStdout': False,
            'Cmd': ['/bin/bash'],
            'Domainname': '',
            'Entrypoint': None,
            'Env': ['PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'],
            'ExposedPorts': {'5000/tcp': {}},
...
compose.cli.verbose_proxy.proxy_callable: docker inspect_image <- ('centos')
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.25/images/centos/json HTTP/1.1" 200 None
compose.cli.verbose_proxy.proxy_callable: docker inspect_image -> {'Architecture': 'amd64',
 'Author': '',
 'Comment': '',
 'Config': {'ArgsEscaped': True,
            'AttachStderr': False,
            'AttachStdin': False,
            'AttachStdout': False,
            'Cmd': ['/bin/bash'],
            'Domainname': '',
            'Entrypoint': None,
...
compose.cli.verbose_proxy.proxy_callable: docker containers <- (all=True, filters={'label': ['com.docker.compose.project=ml', 'com.docker.compose.service=mlos', 'com.docker.compose.oneoff=False']})
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.25/containers/json?limit=-1&all=1&size=0&trunc_cmd=0&filters=%7B%22label%22%3A+%5B%22com.docker.compose.project%3Dml%22%2C+%22com.docker.compose.service%3Dmlos%22%2C+%22com.docker.compose.oneoff%3DFalse%22%5D%7D HTTP/1.1" 200 1745
compose.cli.verbose_proxy.proxy_callable: docker containers -> (list with 1 items)
compose.cli.verbose_proxy.proxy_callable: docker inspect_image <- ('centos')
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.25/images/centos/json HTTP/1.1" 200 None
compose.cli.verbose_proxy.proxy_callable: docker inspect_image -> {'Architecture': 'amd64',
 'Author': '',
 'Comment': '',
 'Config': {'ArgsEscaped': True,
            'AttachStderr': False,
            'AttachStdin': False,
            'AttachStdout': False,
            'Cmd': ['/bin/bash'],
            'Domainname': '',
            'Entrypoint': None,
...
compose.cli.verbose_proxy.proxy_callable: docker inspect_container <- ('18b3ca700791f4475a4fc4fc3241a910a12ffbd9d74298faf852b6f9e6fa55e9')
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.25/containers/18b3ca700791f4475a4fc4fc3241a910a12ffbd9d74298faf852b6f9e6fa55e9/json HTTP/1.1" 200 None
compose.cli.verbose_proxy.proxy_callable: docker inspect_container -> {'AppArmorProfile': '',
 'Args': [],
 'Config': {'AttachStderr': False,
            'AttachStdin': False,
            'AttachStdout': False,
            'Cmd': ['/bin/bash'],
            'Domainname': '',
            'Entrypoint': None,
            'Env': ['PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'],
            'ExposedPorts': {'5000/tcp': {}},
...
compose.parallel.feed_queue: Pending: {<Service: mlos>}
compose.parallel.feed_queue: Starting producer thread for <Service: mlos>
compose.service.execute_convergence_plan: ml_mlos_1 is up-to-date
compose.parallel.parallel_execute_iter: Finished processing: <Service: mlos>
compose.parallel.feed_queue: Pending: set()
Attaching to ml_mlos_1
compose.cli.verbose_proxy.proxy_callable: docker logs <- ('18b3ca700791f4475a4fc4fc3241a910a12ffbd9d74298faf852b6f9e6fa55e9', stdout=True, stderr=True, stream=True, follow=True)
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.25/containers/18b3ca700791f4475a4fc4fc3241a910a12ffbd9d74298faf852b6f9e6fa55e9/logs?stderr=1&stdout=1&timestamps=0&follow=1&tail=all HTTP/1.1" 200 None
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.25/containers/18b3ca700791f4475a4fc4fc3241a910a12ffbd9d74298faf852b6f9e6fa55e9/json HTTP/1.1" 200 None
compose.cli.verbose_proxy.proxy_callable: docker logs -> <docker.types.daemon.CancellableStream object at 0x7fbe14b9ee90>
compose.cli.verbose_proxy.proxy_callable: docker wait <- ('18b3ca700791f4475a4fc4fc3241a910a12ffbd9d74298faf852b6f9e6fa55e9')
compose.cli.verbose_proxy.proxy_callable: docker events <- (filters={'label': ['com.docker.compose.project=ml', 'com.docker.compose.oneoff=False']}, decode=True)
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.25/events?filters=%7B%22label%22%3A+%5B%22com.docker.compose.project%3Dml%22%2C+%22com.docker.compose.oneoff%3DFalse%22%5D%7D HTTP/1.1" 200 None
compose.cli.verbose_proxy.proxy_callable: docker events -> <docker.types.daemon.CancellableStream object at 0x7fbe14b9edd0>

Source: StackOverflow