The docker create
command is used to create a new container from the specified image but doesn’t start it. Or, alternatively, you can use docker container create
also. It’s similar to docker run -d
except the container is never started.
$ docker create [OPTIONS] IMAGE [COMMAND] [ARG...]
Here,
Options: --add-host
, --attach
, --expose
, —memory
or -m
, --label
, —network
, --rm
, —tty
or -t
, etc.
$ docker contaner create -i -t --name cloudycontainer alpine
$ docker container start --attach -i cloudycontainer
/ # echo hello world
hello world
The above is the equivalent of docker run
:
$ docker run -it --name cloudycontainer2 alpine
/ # echo hello world
hello world
$ docker create -v /data --name data ubuntu
$ docker run --rm --volumes-from data ubuntu ls -la /data
Here, it will create the data
volume container and then use it from another container.