本文记录了学习Docker过程中安装、常用命令、理解等,整理自官网、慕课网视频。
Install In Centos
Update docker in centos from 1.13.1 to 18.03.0-ce:
1 | sudo yum remove docker \ |
1 | // If "options: used when "-bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory" |
Start
1 | systemctl start docker |
Introduction
1 | docker run [Image] -> container |
1 | software containerization |
Docker Image
Docker Images are shared, can be copyed to the container but only readable
1 | docker pull hello-world |
Docker Container
The same Image will be copied to different container.
1 | docker run hello-world |
The difference between docker stop
and docker rm
Docker Warehouse
1 | hub.docker.com (default) |
China Warehouse Mac:
Docker Pull
pull image from warehouse
1 | docker pull hello-world |
Docker Run
- copy image to container
- if the image is not exist, ‘docker pull’ firstly
1 | docker run hello-world |
Docker run Nginx
1 | docker pull hub.c.163.com/library/nginx:latest |
Docker Nginx Network
- host链接方式是直接链接主机网卡
- bridge需要链接一个网桥bridge,然后通过网桥链接主机,container有自己独立等ip和端口
1 | docker run --help |
Dockerfile
Define a container with a Dockerfile
1 | docker build -t friendlyname . # Create image using this directory's Dockerfile |
Docker compose
1 | docker-compose up -d # start containers in background |
Services (containers in production)
https://docs.docker.com/get-started/part3/#understanding-services
1 | docker stack ls # List all running applications on this Docker host |
Swarms/Stacks
- A swarm is a group of machines that are running Docker and joined into a cluster
A single stack is capable of defining and coordinating the functionality of an entire application (though very complex applications may want to use multiple stacks).
https://docs.docker.com/get-started/part4/#set-up-your-swarm
https://docs.docker.com/get-started/part5/stacks
network
1 | docker network inspect bridge |
Install in centos
Get Docker CE for CentOS | docker official
Tip: replacing
$ sudo yum install docker-ce
with$ sudo yum install docker
will be faster
File Sharing in Mac D4m-nfs
1 | // step 1: 在Docker中打开Preferences, 点击File Sharing将其它目录全部删掉只保留/tmp目录 |
Laravel Development with Docker
Laravel Development with Docker
ek_ik docker
elasticsearch-analysis-ik
TIPS FOR DEPLOYING NGINX (OFFICIAL IMAGE) WITH DOCKER
Dockerise your PHP application with Nginx and PHP7-FPM
Vagrant vs Docker
- Vagrant 适合用来管理虚拟机,而docker适合用来管理线上环境。
- Vagrant 可以让虚拟机各种系统之间快速切换, 并深层运用系统网络,内存等, 用来管理虚拟机
- docker 实际上一直是局限于linux的docker 容器里, 在Mac\Windows上也是带虚拟Linux