Docker属于对Linux容器技术的一种封装(利用了Linux的namespace和cgroup技术),它提供了简单易用的容器使用接口,是目前最流行的 Linux 容器解决方案。Docker将应用程序与该程序的依赖打包在一个文件里面,运行这个文件,就会生成一个虚拟容器。程序在这个虚拟容器里运行,就好像在真实的物理机上运行一样。下图是虚拟机和容器的对比,左边是传统的虚拟机,右边是Docker。
Docker属于对Linux容器技术(LXC)的一种封装(利用了Linux的namespace和cgroup技术),它提供了简单易用的容器使用接口,是目前最流行的 Linux 容器解决方案。Docker将应用程序与该程序的依赖打包在一个文件里面,运行这个文件,就会生成一个虚拟容器。程序在这个虚拟容器里运行,就好像在真实的物理机上运行一样。下图是虚拟机和容器的对比,左边是传统的虚拟机,右边是Docker。
![](./res/docker_vs_vm.png)
@ -299,7 +301,7 @@ select user, host, plugin, authentication_string from user where user='root';
Creating network "temp_default" with the default driver
Creating temp_web-server_1 ... done
Creating temp_redis-master_1 ... done
Creating temp_api-server_1 ... done
Attaching to temp_redis-master_1, temp_web-server_1, temp_api-server_1
redis-master_1 | 1:C 05 Dec 2019 11:57:26.828 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
redis-master_1 | 1:C 05 Dec 2019 11:57:26.828 # Redis version=5.0.6, bits=64, commit=00000000, modified=0, pid=1, just started
redis-master_1 | 1:C 05 Dec 2019 11:57:26.828 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
redis-master_1 | 1:M 05 Dec 2019 11:57:26.831 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
redis-master_1 | 1:M 05 Dec 2019 11:57:26.831 # Server initialized
redis-master_1 | 1:M 05 Dec 2019 11:57:26.831 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
redis-master_1 | 1:M 05 Dec 2019 11:57:26.831 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
redis-master_1 | 1:M 05 Dec 2019 11:57:26.831 * Ready to accept connections
Creating network "composeapp_default" with the default driver
Building product-service
Step 1/5 : FROM python:3
---> e497dabd8450
Step 2/5 : ADD . /root/product-service
---> fbe62813d595
Removing intermediate container 6579e845565a
Step 3/5 : WORKDIR /root/product-service
---> 3a722675e3b1
Removing intermediate container 57fc490436ce
Step 4/5 : RUN pip install -r requirements.txt
---> Running in cadc2d0c1b9b
... ...
---> fc747fc11f4a
Removing intermediate container cadc2d0c1b9b
Step 5/5 : CMD python api.py
---> Running in ecbbd2a69906
---> 637e760f2e5b
Removing intermediate container ecbbd2a69906
Successfully built 637e760f2e5b
WARNING: Image for service product-service was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Creating composeapp_redis-master_1 ... done
Creating composeapp_web-site_1 ... done
Creating composeapp_product-service_1 ... done
Attaching to composeapp_redis-master_1, composeapp_web-site_1, composeapp_product-service_1