Docker is a recent hot technology, it seems that no use of Docker is outdated, so I also in a personal project to use Docker, but also have some practical experience, to share with you.
The first is to install and configure the local Docker environment, because Docker is the Linux container engine, so the host must be Linux, Windows and Mac systems using Docker must first install Boot2docker to run a minimized Linux virtual machine with Docker dependencies as a host, but you can also run a full Linux desktop system with a virtual machine and then install Docker on it. The latter method is more recommended for individuals.
Domestic even Docker Hub pull mirror speed is relatively slow, we recommend the use of registration free Daocloud personal acceleration link, after registration can also have boot2docker accelerated download link.
If you want to run Docker on the server but you don't have a server, it is recommended to use Digitalocean's San Francisco VPS, register tutorial, Welcome to use my promotion link to register, you can get $10 after registration, equivalent to two months of free use of the minimum capacity of droplet, If you spend $25, I can get $25.
With the environment, if you want to learn Docker in the system, you can refer to the following books and series of articles.
- The first Docker book (watercress)
- Docker Technology Introduction and Combat (watercress) online reading
- The in-depth Docker series
Use Docker as much as possible to build the image using Dockerfile, create a github Repository for Dockerfile, and then use the Docker hub to associate to this GitHub Repository, you can automatically build the image, Each commit will trigger an automatic build. Large Dockerfile modifications before submitting to GitHub it is best to do a local walkthrough to avoid automatic build failures. Domestic network local running Docker image installation dependent program is slow, you can use the domestic mirror software source, for example, if it is Ubuntu can run the following command.
sed ‘s/archive\.ubuntu\.com/mirrors\.zju\.edu\.cn/‘ -i /etc/apt/sources.list
Some details of Dockerfile can be found in the official Dockerfile, such as Redis Dockerfile
As much as one container (mirror) is responsible for running an application, multiple containers can be simply allocated using FIG. For example, my Coolcantonese project uses 3 containers to run Python, Redis, and Nginx, respectively.
Fig.xml:
wechat: image: kk17/coolcantonese entrypoint: python command: wechat.py ports: - "80:8888" volumes: - .:/Cantonese - /Cantonese_audio links: - redisredis: image: redisnginx: image: nginx volumes_from: - wechat volumes: - configs/nginx.conf:/etc/nginx/nginx.conf:ro ports: - "9090:9090"
The above is my some basic practice of Docker, welcome to communicate more.
Personal blog Links
Docker Getting Started practice summary