docker run IMAGE_NAME COMMAND[s]
docker ps
docker ps -a
docker run -d IMAGE_NAME COMMAND[s]
$ docker create -P --expose=1234 python:2.7 python -m SimpleHTTPServer 1234 a842945e2414132011ae704b0c4a4184acc4016d199dfd4e7181c9b89092de13
$ docker ps -a CONTAINER ID IMAGE COMMAND CREATED ... NAMES a842945e2414 python:2.7 "python -m SimpleHTT 8 seconds ago ... fervent_hodgkin $ docker start a842945e2414 a842945e2414 $ docker ps CONTAINER ID IMAGE COMMAND ... NAMES a842945e2414 python:2.7 "python -m SimpleHTT ... fervent_hodgkin
However, the container has not yet disappeared (i.e., the filesystem of the container is still there);
$ docker restart a842945e2414 a842945e2414 $ docker ps CONTAINER ID IMAGE COMMAND ... a842945e2414 python:2.7 "python -m SimpleHTT ... $ docker kill a842945e2414 a842945e2414 $ docker rm a842945e2414 a842945e2414 $ docker ps -a CONTAINER ID IMAGE COMMAND CREATED NAMES
FROM busybox
ENV foo=bar
$ docker build -t busybox2 . Sending build context to Docker daemon 2.048 kB Step 0 : FROM busybox 24 | Chapter 1: Getting Started with Docker STATUS PORTS NAMES www.it-ebooks.info latest: Pulling from library/busybox cf2616975b4a: Pull complete 6ce2e90b0bc7: Pull complete 8c2e06607696: Pull complete Digest: sha256:df9e13f36d2d5b30c16bfbf2a6110c45ebed0bfa1ea42d357651bc6c736d5322 Status: Downloaded newer image for busybox:latest ---> 8c2e06607696 Step 1 : ENV foo bar ---> Running in f46c59e9bdd6 ---> 582bacbe7aaa
and you can launch a container based on it to check that the container has the environment variable foo set to bar:
$ docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE busybox2 latest 582bacbe7aaa 6 seconds ago 2.433 MB busybox latest 8c2e06607696 3 months ago 2.433 MB
$ docker run busybox2 env | grep foo foo=bar