Docker Community Forums

Share and learn in the Docker community.

Docker Compose no Exit code on log Error

I want to receive exit codes from docker-compose when receiving Error: log messages

When for example providing an impossible port mapping, the creation fails with Errors in the log:

Creating containername... 
ERROR: for containernameCannot create container for service servicename: invalid port specification: "100000"
ERROR: for servicenameCannot create container for service servicename: invalid port specification: "100000" Encountered errors while bringing up the project.

However, the exit code ($?) is 0

Am I missing something?
Does docer-compose creade exit codes?

Best Regards

docker may fail due to many things in the build process. To find the solution here is my advice

Type docker ps -la (to list all containers that exited with error code or failed to start
In the result, you should look out for the name of the container
Then check the logs using: docker logs

The error is known and simple. Port 100000 is impossible.

The problem lies in the missing exit code when starting with an incorrect yml file.

Hi, i think the closest you will come with using docker-compose is the --exit-code-from flag:

  --exit-code-from SERVICE   Return the exit code of the selected service
                              container. Implies --abort-on-container-exit.

The problem is here, I believe, that no container has been constructed yet.
Also, I have multiple containers, such a single service solution does unfortunately not apply.