DEV Community

Fabio Bazurto Blacio
Fabio Bazurto Blacio

Posted on

Bug: Docker-compose up?

ERROR

I've been using a bash script to do docker operations in past by using docker-compose. So one day, I started to receive this error:

**ERROR: for my_docker_container_1 'ContainerConfig'**

CAUSE

The statement docker-compose is not working anymore for recent versions of Docker Compose. This error is very common when you have updated to the latest version of Docker Compose ( I'm 2.27.0). Docker Compose syntax changed.

docker-compose up -d my_docker_container

SOLUTION

In order to start/stop containers you will need to remove "-" and run command like this.

docker compose up -d my_docker_container

Top comments (2)

Collapse
 
ajeetraina profile image
Ajeet Singh Raina

The difference between docker-compose and docker compose lies in the versions of Docker Compose and the language they were written in.

docker-compose refers to version one of Docker Compose, which was first released in 2014 and written in Python. This version typically includes a top-level version element in the compose.yml file, with values ranging from 2.0 to 3.8, referring to the specific file formats.
On the other hand, docker compose refers to version two of Docker Compose, which was announced in 2020 and written in Go. This version ignores the version top-level element in the compose.yml file.

For most projects, switching to Compose V2 requires no changes to the Compose YAML or your development workflow. It's recommended to use docker compose instead of docker-compose as it provides additional flexibility and removes the requirement for a docker-compose compatibility alias. However, Docker Desktop continues to support a docker-compose alias to redirect commands to docker compose for convenience and improved compatibility with third-party tools and scripts.

To switch to Compose V2, the easiest and recommended way is to make sure you have the latest version of Docker Desktop, which bundles the Docker Engine and Docker CLI platform including Compose V2. With Docker Desktop, Compose V2 is always accessible as docker compose. Additionally, the Use Compose V2 setting is turned on by default, which provides an alias from docker-compose.

Collapse
 
fabiobazurtobla profile image
Fabio Bazurto Blacio • Edited

You are right. I noticed this docker compose was included into my docker context rather than Py package.
You can check it by executing:
docker-compose version
and
docker compose version

They are pointing to a different context (inside/outside docker)

Thank you so much for this information @ajeetraina