You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When attempting to use the Docker Engine API (POST /containers/create) with a JSON payload generated from a Docker Compose file, the API returns the following error:
{
"message": "config cannot be empty in order to create a container"
}
Expected Behavior:
The container should be created successfully using the Docker Engine API.
Actual Behavior:
The API returns:
{
"message": "config cannot be empty in order to create a container"
}
Analysis:
The JSON generated by docker compose config --format=json is not directly compatible with the POST /containers/create endpoint.
The Engine API requires specific fields like Image, HostConfig, and NetworkingConfig to be properly structured. However, the JSON generated by Docker Compose includes additional metadata and lacks the required HostConfig format.
Compose Version
Docker Compose version v2.29.7
docker-compose version 1.29.2, build unknown
docker-py version: 5.0.3
CPython version: 3.10.12
OpenSSL version: OpenSSL 3.0.2 15 Mar 2022
sertunc
changed the title
[BUG] config cannot be empty Error When Using Docker Engine API with Docker Compose JSON Output
Config cannot be empty error when using docker engine API with Docker Compose JSON Output
Jan 6, 2025
docker compose config is not intended to produce a docker engine API payload. What made you think this was the case?
I am developing a client application that uses Docker Engine APIs. I want to update the image of a running container when a new image becomes available. That's why I aimed to use the data from the Docker Compose JSON. If you have a better idea, please share it. Thanks! <3
Description
When attempting to use the Docker Engine API (POST /containers/create) with a JSON payload generated from a Docker Compose file, the API returns the following error:
Steps To Reproduce
Generate JSON using the following command
docker compose -f docker-compose.yml config --format=json
Output
Expected Behavior:
The container should be created successfully using the Docker Engine API.
Actual Behavior:
The API returns:
Analysis:
The JSON generated by docker compose config --format=json is not directly compatible with the POST /containers/create endpoint.
The Engine API requires specific fields like Image, HostConfig, and NetworkingConfig to be properly structured. However, the JSON generated by Docker Compose includes additional metadata and lacks the required HostConfig format.
Compose Version
Docker Environment
Anything else?
However, when manually crafting the JSON in the format below, the container is created successfully:
The text was updated successfully, but these errors were encountered: