Docker
Installation
Install docker using your package manager and then start the service.
To play with docker, you will need to run things as root or be part of a group that has access to docker's socket.
See more here: https://docs.docker.com/engine/installation/linux/linux-postinstall/
Usage Reference
| Command | Description |
|---|---|
docker images
|
Lists docker images that you created or pulled using docker pull
|
docker pull
|
Pulls a docker image from a registry (can be from docker.io or a private registry)
|
docker run
|
Runs a command in a container. Eg. docker run alpine ls -l
|
docker ps
|
Lists containers that are running.
Pass |
docker port
|
shows the port mapping between the container and the host. |
docker stop
|
Stop a container |
docker kill
|
?? |
docker rm
|
Removes a container. Use -rf to stop and remove.
|
Creating an Image
To create an image:
- Create a directory containing any custom files
- Create a
Dockerfilein the directory. - Run
docker buildto build the image
Dockerfile
The docker file should a the minimum contain:
# The base image to use
FROM baseimage:version
# What to run when the image is started. This can contain any number of RUN or COPY commands
RUN yum install any-dependencies
# Expose any ports that are required
EXPOSE 80
# run the application
CMD ["python", "/some/app.py"]
Deploying an Application
Use Docker Swarm mode to deploy an application that relies on multiple services where each is a separate docker instance.
The swarm file lets you define each server that is part of the application.
See more at https://github.com/docker/labs/blob/master/beginner/chapters/votingapp.md
Questions
- How are updates to the base image done? Does it automatically update containers relying on it? Or will containers need to be rebuilt again?
- How is data kept persistent? Does it need to be copied out/in everytime it is to be rebuilt?
- NFS access from the container?
- Domain trust - is it the same as a regular VM?
Could it be used for...
- dictd (probably easily)
- WebCat (swarm tomcat + MySQL?)
- ftp (Requires NFS)
- compute balancer
- firewall manager (swarm apache + MySQL)