Docker
Basic commands
List all containers
docker ps -a
List all my images
docker images
Commit your container to a new named image
docker commit <container> <some_name>
Basics
https://gist.github.com/dtuite/b595308c11e5bd251117
There are two programs:
The docker daemon - a server process which manages all the containers The docker client - a remote control for the daemon
You can list the commands of the docker client by typing
docker
with no arguments.
You can use container images which have been created by other people. You find them online in the docker index. You can search for images using
docker search [keywords].
Container images are downloaded using
docker pull [image name].
Containers are unstarted by default. You can run commands in a container using the syntax:
docker run [image name] [command to run]
For example, we can install the program "ping" in the container with the command (note: the -y flag instructs apt-get to not ask us to confirm the changes we're about to make):
docker run learn/tutorial apt-get install -y ping
The changes we have made to the container are not yet saved. To save the container, we first need to find it's id:
docker ps -l
Once we have the first few chars of the id, we can save the container with a new image name using:
docker commit [id] [new image name]
We can now run the ping command on our container using:
docker run learn/ping ping www.google.com
We can use
docker ps
and
docker inspect [container id]
to learn about available containers.
We can share images using
docker push [image name.
Install Foswiki container
on Ubuntu
docker run -t -i -p 8888:80 svendowideit/ubuntu-foswiki /bin/bash then goto http://localhost:8888/foswiki
on Centos
- Create a folder
- Create the Dockerfile similar to https://github.com/SvenDowideit/dockerfiles/blob/master/centos-foswiki/Dockerfile
docker build -t svendowideit/centos-foswiki .
run the image by:
docker run -p 8080:80 -i -t svendowideit/centos-foswiki /bin/bash