Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create Docker container from image without starting it

Tags:

docker

As part of my deployment strategy, I am managing Docker containers with Upstart.

To do that, I need to pull an image from a registry and create a named container (as suggested on Upstart script to run container won't manage lifecycle )

Is there a way to create the container without first running the image? I don't want to have to start a container (which may introduce side effects), stop it, and then manage elsewhere.

For example, something like:

docker.io create -e ENV1=a -e ENV2=b -p 80:80 --name my_first_container sample/containe
like image 914
Marshall Anschutz Avatar asked Jul 21 '14 18:07

Marshall Anschutz


People also ask

How do I create a docker container without running it?

If we want to create a container without running it immediately, we can use the Docker Create command below. The command will create a container called appserver using the Python Docker image. If I run docker ps I won't see it because it is not running.

How do I create a docker container from an image?

The docker container create (or shorthand: docker create ) command creates a new container from the specified image, without starting it. When creating a container, the docker daemon creates a writeable container layer over the specified image and prepares it for running the specified command.

Can we generate docker file from image?

You can use Portainer.io portainer.io It's a web app that runs inside a docker container used to manage all (almost) stuff about your containers. Even images recepies.

Can a docker container be created without a base OS image?

No its not like that. To create any docker image using DockerFile, You need to start with a base docker image. That base docker image can be anything, Like an empty image as well, In the docker file in your example the FROM section says ubuntu, it means its assuming ubuntu as the base image.


1 Answers

In case anyone else comes across this question, it can now be done with the docker create command. See https://docs.docker.com/engine/reference/commandline/create/

like image 111
Adrian Mouat Avatar answered Sep 30 '22 06:09

Adrian Mouat