0

Consider the following setup.

Precondition: have a healthy image i.e. service starts up.

E.g.

docker run -d IMAGE

Then, with the Python plugin docker-py, consider the following code which should be equivalent, only with added port mapping.

ingreedy = client.containers.create("openfoodbroker/ingreedy.service", 
                                     name="ingreedy_service",
                                     detach=True,
                                     ports={'5000': 5000})
print(ingreedy.id)

This code prints out the container ID and I can remove the container using docker rm -f, but:

  • port 5000 is not open;
  • the container does not show up on docker ps

Any ideas?

2

docker.containers.create() is documented to:

Create a container without starting it. Similar to docker create.

Either call docker.containers.run() instead, or given the container object returned from create(), call ingreedy.start().

(docker ps by default only shows running containers; docker ps -a should show the container in a "created" state.)

| 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.