Docker installed
docker-machine installed (Mac/Win)
Good internet connection
Running docker in interactive mode allows a developer to:
- understand the environment
- debug when things go wrong
- research
We will be working with 2 images for these labs. ubuntu
and kensipe/tomcat
. The first time they are reference it will take several minutes as these images are pulled for the public repository. After that command-line references will run very quickly. It may be best to pull these images prior to starting the lab. To pull run: docker pull ubuntu
and docker pull kensipe/tomcat
.
If you haven't yet, start the docker-machine: docker-machine start
and set the environment eval $(docker-machine env)
.
-
enter interactive mode:
docker run -it ubuntu /bin/bash` or `docker run -it ubuntu
-
add a text file named
owner.txt
with your name in it.echo "ken sipe" > owner.txt
-
exit the container type:
ctrl+p, ctrl+q
-
list the running dockers
docker ps
NOTE: Experiment with variations here. docker ps -a
, docker ps -l
, docker ps -q
, docker ps -lq
NOTE: It is common to set an alias for dl (docker last): alias dl='docker ps -lq'
-
diff on the container ID (SHA)
docker diff $(docker ps -lq) or docker diff `dl`
-
attach to the container
docker attach `dl`
-
exit the container. type:
exit
-
commit your container
docker commit `dl` owner
-
display owner information from your container in non-interactive mode
docker run owner cat owner.txt
- enter interactive mode
docker run -it ubuntu
- install figlet
apt-get update && apt-get install figlet
- commit image
docker commit `dl` figlet
- run container
docker run figlet figlet hello