This note is about the problems that I met while using Docker.
What is Docker
Definition[1]
Build, Ship, and Run Any App, Anywhere
Components
- Docker Client
- Docker Daemon
- Docker Image
- Docker Registry
- Docker Container
Architecture
Difference between docker containers and virtual machines
Docker Containers | Virtual Machines |
---|---|
Core Tech[2]
-
Linux Namespace(ns)
- pid namespace
- net namespace
- ipc namespace
- mnt namespace
- uts namespace
- user namespace
-
Contral Groups(cgroups)
- blkio
- cpu
- cpuacct
- cpuset
- devices
- freezer
- memory
- net_cls
- ns
-
AUFS(AnotherUnionFS)
-
Security
- Secured by kernel namespaces and cgroups.
- Secured by Docker Deamon APIs.
- Secured by Linux’s solution such as AppArmor, SELinux.
Requirement
See official guide.
Install
See official guide.
Configuration
Use Dockerfile
to build the image
Often used commands
- ADD
- ENV
- EXPOSE
- FROM
- RUN
- CMD
Set Java
Use Dockerfile
to build the image.
Set Locale
Configure the locales in the host.
Use Dockerfile
to build the image.
Set Port
Use Dockerfile
to build the image.
MySQL
Install in the host.
Vsftpd
Install in the host.
Often used commands
RUN
This command creates a container from a docker image.
-v Better use absolute path.
START
This command starts a container which is stopped.
STOP
This command stops a container which is running.
ATTACH
This command enters into a started container.
While you are in a container, you cannot leave it with
ctrl
+c
. This will stop the container. Usectrl
+p
+q
instead.Use
attach
to enter it again.
PS
This command displays containers.
IMAGES
This command displays images.
RM
This command removes a container.
The container has to be stopped.
RMI
This command removes an image
COMMIT
This command commits changes in a container to a image.
PUSH
This command pushes local image to a repository.
PULL
This command pulls image from a repository.
SAVE
This command saves image to a local file.
LOAD
This command loads image from a local file.
REMOVE UNUSED IMAGES
This command removes all unused images.
DockerHub
Using different tags to store different versions.
Reference
-
https://www.docker.com/
-
http://www.infoq.com/cn/articles/docker-core-technology-preview
竟然无法拒绝你的打赏