一、安装docker compose

二进制包安装

1、安装 Docker Compose 从 官方 GitHub Release 处直接下载编译好的二进制文件即可

# curl -L https://github.com/docker/compose/releases/download/1.8.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose

  1. [root@bogon ~]# curl -L https://github.com/docker/compose/releases/download/1.8.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
  2. % Total % Received % Xferd Average Speed Time Time Time Current
  3. Dload Upload Total Spent Left Speed
  4. --:--:-- :: --:--:--
  5. 7783k 7783k 471k :: :: --:--:-- 1484k
  6. [root@bogon ~]#
  7. [root@bogon ~]# cd /usr/local/bin/
  8. [root@bogon bin]#
  9. [root@bogon bin]# ls
  10. docker-compose
  11. [root@bogon bin]# ll
  12. total
  13. -rw-r--r--. root root Apr : docker-compose
  14. [root@bogon bin]#

2、并为安装脚本添加执行权限

# chmod 755 docker-compose

  1. [root@bogon bin]# chmod docker-compose
  2. [root@bogon bin]#
  3. [root@bogon bin]# ll
  4. total
  5. -rwxr-xr-x. root root Apr : docker-compose
  6. [root@bogon bin]#

3、查看安装是否成功

# docker-compose -v

  1. [root@bogon bin]# docker-compose -v
  2. docker-compose version 1.8., build f3628c7

4、对于卸载如果是二进制包方式安装的,删除二进制文件即可。

# rm -rf /usr/local/bin/docker-compose

二、使用docker-compose

1、为项目创建一个目录

# mkdir composetest

# cd composetest/

  1. [root@localhost ~]# mkdir composetest
  2. [root@localhost ~]#
  3. [root@localhost ~]# cd composetest/
  4. [root@localhost composetest]#

2、创建一个app.py在项目目录中调用的文件:

# vi app.py

  1. [root@localhost composetest]# vi app.py
  2. import time
  3.  
  4. import redis
  5. from flask import Flask
  6.  
  7. app = Flask(__name__)
  8. cache = redis.Redis(host='redis', port=)
  9.  
  10. def get_hit_count():
  11. retries =
  12. while True:
  13. try:
  14. return cache.incr('hits')
  15. except redis.exceptions.ConnectionError as exc:
  16. if retries == :
  17. raise exc
  18. retries -=
  19. time.sleep(0.5)
  20.  
  21. @app.route('/')
  22. def hello():
  23. count = get_hit_count()
  24. return 'Hello World! I have been seen {} times.\n'.format(count)
  25.  
  26. if __name__ == "__main__":
  27. app.run(host="0.0.0.0", debug=True)

redis是应用程序网络上redis容器的主机名。我们使用Redis的默认端口6379

3、创建requirements.txt项目目录中调用的另一个文件

# vi requirements.txt

  1. [root@localhost composetest]# vi requirements.txt
  2. flask
  3. redis

4、创建dockerfile文件

# vi Dockerfile

  1. [root@localhost composetest]# vi Dockerfile
  2. FROM python:3.4-alpine
  3. ADD . /code
  4. WORKDIR /code
  5. RUN pip install -r requirements.txt
  6. CMD ["python", "app.py"]

说明:

FROM:从Python 3.4镜像开始构建映像

ADD:添加当前目录文件到code

WORKDIR:定义工作目录code

RUN:在构建的镜像中运行命令

CMD:将容器的默认命令设置为python app.py

5、在Compose文件中定义服务

创建docker-compose.yml

# vi docker-compose.yml

  1. [root@localhost composetest]# vi docker-compose.yml
  2. version: '2'
  3. services:
  4. web:
  5. build: .
  6. ports:
  7. - "5000:5000"
  8. redis:
  9. image: "redis:alpine"

注意:官网上写的是version '3',然后运行docker-compose up命令时报错,然后把3改成2

  1. [root@localhost composetest]# ls
  2. app.py docker-compose.yml Dockerfile requirements.txt
  3. [root@localhost composetest]#
  4. [root@localhost composetest]# docker-compose -v
  5. docker-compose version 1.8., build f3628c7
  6. [root@localhost composetest]#
  7. [root@localhost composetest]# docker-compose up
  8. ERROR: Version in "./docker-compose.yml" is unsupported. You might be seeing this error because you're using the wrong Compose file version. Either specify a version of "2" (or "2.0") and place your service definitions under the `services` key, or omit the `version` key and place your service definitions at the root of the file to use version 1.
  9. For more on the Compose file format versions, see https://docs.docker.com/compose/compose-file/

此Compose文件定义了两个服务,web和redis

该web服务使用从Dockerfile当前目录中构建的镜像

将容器上的公开端口5000转发到主机上的端口5000。

我们使用Flask Web服务器的默认端口5000

6、使用Compose构建并运行您的应用程序

从项目目录中,通过运行启动应用程序

# docker-compose up

  1. [root@localhost composetest]# docker-compose up
  2. Creating network "composetest_default" with the default driver
  3. Building web
  4. Step / : FROM python:3.4-alpine
  5. Trying to pull repository docker.io/library/python ...
  6. 3.4-alpine: Pulling from docker.io/library/python
  7. 8e402f1a9c57: Pull complete
  8. cda9ba2397ef: Pull complete
  9. aafecf9bbbfd: Pull complete
  10. bc2e7e266629: Pull complete
  11. e1977129b756: Pull complete
  12. Digest: sha256:c210b660e2ea553a7afa23b41a6ed112f85dbce25cbcb567c75dfe05342a4c4b
  13. Status: Downloaded newer image for docker.io/python:3.4-alpine
  14. ---> c06adcf62f6e
  15. Step / : ADD . /code
  16. ---> d700bcab2d17
  17. Removing intermediate container 3f5775b19826
  18. Step / : WORKDIR /code
  19. ---> eefa4e6c6f62
  20. Removing intermediate container 8bc944b6cf72
  21. Step / : RUN pip install -r requirements.txt
  22. ---> Running in 7de50b315d7c
  23.  
  24. DEPRECATION: Python 3.4 support has been deprecated. pip 19.1 will be the last one supporting it. Please upgrade your Python as Python 3.4 won't be maintained after March 2019 (cf PEP 429).
  25. Collecting flask (from -r requirements.txt (line ))
  26. Downloading https://files.pythonhosted.org/packages/7f/e7/08578774ed4536d3242b14dacb4696386634607af824ea997202cd0edb4b/Flask-1.0.2-py2.py3-none-any.whl (91kB)
  27. Collecting redis (from -r requirements.txt (line ))
  28. Downloading https://files.pythonhosted.org/packages/ac/a7/cff10cc5f1180834a3ed564d148fb4329c989cbb1f2e196fc9a10fa07072/redis-3.2.1-py2.py3-none-any.whl (65kB)
  29. Collecting Werkzeug>=0.14 (from flask->-r requirements.txt (line ))
  30. Downloading https://files.pythonhosted.org/packages/18/79/84f02539cc181cdbf5ff5a41b9f52cae870b6f632767e43ba6ac70132e92/Werkzeug-0.15.2-py2.py3-none-any.whl (328kB)
  31. Collecting Jinja2>=2.10 (from flask->-r requirements.txt (line ))
  32. Downloading https://files.pythonhosted.org/packages/1d/e7/fd8b501e7a6dfe492a433deb7b9d833d39ca74916fa8bc63dd1a4947a671/Jinja2-2.10.1-py2.py3-none-any.whl (124kB)
  33. Collecting click>=5.1 (from flask->-r requirements.txt (line ))
  34. Downloading https://files.pythonhosted.org/packages/fa/37/45185cb5abbc30d7257104c434fe0b07e5a195a6847506c074527aa599ec/Click-7.0-py2.py3-none-any.whl (81kB)
  35. Collecting itsdangerous>=0.24 (from flask->-r requirements.txt (line ))
  36. Downloading https://files.pythonhosted.org/packages/76/ae/44b03b253d6fade317f32c24d100b3b35c2239807046a4c953c7b89fa49e/itsdangerous-1.1.0-py2.py3-none-any.whl
  37. Collecting MarkupSafe>=0.23 (from Jinja2>=2.10->flask->-r requirements.txt (line ))
  38. Downloading https://files.pythonhosted.org/packages/b9/2e/64db92e53b86efccfaea71321f597fa2e1b2bd3853d8ce658568f7a13094/MarkupSafe-1.1.1.tar.gz
  39. Building wheels for collected packages: MarkupSafe
  40. Building wheel for MarkupSafe (setup.py): started
  41. Building wheel for MarkupSafe (setup.py): finished with status 'done'
  42. Stored in directory: /root/.cache/pip/wheels/f2/aa//0edf07a1b8a5f5f1aed7580fffb69ce8972edc16a505916a77
  43. Successfully built MarkupSafe
  44. Installing collected packages: Werkzeug, MarkupSafe, Jinja2, click, itsdangerous, flask, redis
  45. Successfully installed Jinja2-2.10. MarkupSafe-1.1. Werkzeug-0.15. click-7.0 flask-1.0. itsdangerous-1.1. redis-3.2.
  46. ---> 3be612bb7eee
  47. Removing intermediate container 7de50b315d7c
  48. Step / : CMD python app.py
  49. ---> Running in c6bd8cb54574
  50. ---> 70884628abf7
  51. Removing intermediate container c6bd8cb54574
  52. Successfully built 70884628abf7
  53. WARNING: Image for service web was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
  54. Pulling redis (redis:alpine)...
  55. Trying to pull repository docker.io/library/redis ...
  56. alpine: Pulling from docker.io/library/redis
  57. 8e402f1a9c57: Already exists
  58. 4c2113a1bbc9: Pull complete
  59. a4b5ad98d179: Pull complete
  60. 779a3abe033a: Pull complete
  61. 84714e9d5602: Pull complete
  62. 8e66c4c614cb: Pull complete
  63. Digest: sha256:a228f66132cd46a53fd818443c42458af5d6a3e1231df25184304b8e732e51c4
  64. Status: Downloaded newer image for docker.io/redis:alpine
  65. Creating composetest_web_1
  66. Creating composetest_redis_1
  67. Attaching to composetest_redis_1, composetest_web_1
  68. redis_1 | :C Apr ::05.157 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
  69. redis_1 | :C Apr ::05.158 # Redis version=5.0., bits=, commit=, modified=, pid=, just started
  70. redis_1 | :C Apr ::05.158 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
  71. redis_1 | :M Apr ::05.165 * Running mode=standalone, port=.
  72. redis_1 | :M Apr ::05.165 # WARNING: The TCP backlog setting of cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of .
  73. redis_1 | :M Apr ::05.165 # Server initialized
  74. redis_1 | :M Apr ::05.165 # WARNING overcommit_memory is set to ! 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.
  75. redis_1 | :M Apr ::05.165 # 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.
  76. redis_1 | :M Apr ::05.165 * Ready to accept connections
  77. web_1 | * Serving Flask app "app" (lazy loading)
  78. web_1 | * Environment: production
  79. web_1 | WARNING: Do not use the development server in a production environment.
  80. web_1 | Use a production WSGI server instead.
  81. web_1 | * Debug mode: on
  82. web_1 | * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
  83. web_1 | * Restarting with stat
  84. web_1 | * Debugger is active!
  85. web_1 | * Debugger PIN: --
  86. web_1 | 172.18.0.1 - - [/Apr/ ::] "GET / HTTP/1.1" -
  87. web_1 | 172.18.0.1 - - [/Apr/ ::] "GET /favicon.ico HTTP/1.1" -
  88. web_1 | 172.18.0.1 - - [/Apr/ ::] "GET / HTTP/1.1" -

页面就停留在这里了,然后打开浏览器输入地址访问

http://IP地址:5000/

刷新页面,数字应该增加。

切换到另一个终端窗口,然后键入

# docker images

查看本地镜像

  1. [root@localhost ~]# docker images
  2. REPOSITORY TAG IMAGE ID CREATED SIZE
  3. composetest_web latest 70884628abf7 minutes ago 84.5 MB
  4. docker.io/python 3.4-alpine c06adcf62f6e weeks ago 72.9 MB
  5. docker.io/redis alpine 07103bda7d12 weeks ago 51.6 MB

通过docker-compose down 在第二个终端的项目目录中运行,或者在启动应用程序的原始终端中按CTRL + C来停止应用程序。

  1. web_1 | 172.18.0.1 - - [/Apr/ ::] "GET / HTTP/1.1" -
  2. ^CGracefully stopping... (press Ctrl+C again to force)
  3. Stopping composetest_redis_1 ... done
  4. Stopping composetest_web_1 ... done
  5. [root@localhost composetest]#

7、编辑Compose文件以添加绑定装载

编辑docker-compose.yml在项目目录添加绑定安装的web服务:

# vi docker-compose.yml

  1. version: ''
  2. services:
  3. web:
  4. build: .
  5. ports:
  6. - "5000:5000"
  7. volumes:
  8. - .:/code
  9. redis:
  10. image: "redis:alpine"

新volumes密钥将主机上的项目目录(当前目录)/code安装到容器内部,允许您动态修改代码,而无需重建镜像。

8、使用Compose重新构建并运行应用程序

从项目目录中,键入docker-compose up以使用更新的Compose文件构建应用程序,然后运行它。

# docker-compose up

提示我这个项目正在运行,不能再次开启

  1. [root@localhost composetest]# docker-compose up
  2. Recreating composetest_web_1
  3. Starting composetest_redis_1
  4.  
  5. ERROR: for web Cannot start service web: driver failed programming external connectivity on endpoint composetest_web_1 (db4744d1208089127c52e9b1e201bfc0b94a66db86e4d266e356c15e7f24b147): (iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d / --dport -j DNAT --to-destination 172.18.0.3: ! -i br-012aad8c1511: iptables: No chain/target/match by that name.
  6. (exit status ))
  7. ERROR: Encountered errors while bringing up the project.

然后执行关闭命令

# docker-compose down

  1. [root@localhost composetest]# docker-compose down
  2. Stopping composetest_redis_1 ... done
  3. Removing composetest_web_1 ... done
  4. Removing composetest_redis_1 ... done
  5. Removing 2386004fa63c_composetest_web_1 ... done
  6. Removing network composetest_default
  7. [root@localhost composetest]#

再次开启

# docker-compose up

  1. [root@localhost composetest]# docker-compose up
  2. Creating network "composetest_default" with the default driver
  3. ERROR: Failed to Setup IP tables: Unable to enable SKIP DNAT rule: (iptables failed: iptables --wait -t nat -I DOCKER -i br-12896ecfa420 -j RETURN: iptables: No chain/target/match by that name.
  4. (exit status ))

又报错了,还好这个错误很常见,重启docker服务即可解决

  1. [root@localhost composetest]# systemctl restart docker
  2. [root@localhost composetest]#
  3. [root@localhost composetest]# docker-compose up
  4. Creating network "composetest_default" with the default driver
  5. Creating composetest_web_1
  6. Creating composetest_redis_1
  7. Attaching to composetest_redis_1, composetest_web_1
  8. redis_1 | :C Apr ::11.016 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
  9. redis_1 | :C Apr ::11.016 # Redis version=5.0., bits=, commit=, modified=, pid=, just started
  10. redis_1 | :C Apr ::11.016 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
  11. redis_1 | :M Apr ::11.018 * Running mode=standalone, port=.
  12. redis_1 | :M Apr ::11.018 # WARNING: The TCP backlog setting of cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of .
  13. redis_1 | :M Apr ::11.018 # Server initialized
  14. redis_1 | :M Apr ::11.018 # WARNING overcommit_memory is set to ! 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.
  15. redis_1 | :M Apr ::11.018 # 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.
  16. redis_1 | :M Apr ::11.018 * Ready to accept connections
  17. web_1 | * Serving Flask app "app" (lazy loading)
  18. web_1 | * Environment: production
  19. web_1 | WARNING: Do not use the development server in a production environment.
  20. web_1 | Use a production WSGI server instead.
  21. web_1 | * Debug mode: on
  22. web_1 | * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
  23. web_1 | * Restarting with stat
  24. web_1 | * Debugger is active!
  25. web_1 | * Debugger PIN: --

再次浏览器访问

9、更新应用程序

由于应用程序代码现在使用卷安装到容器中,因此您可以更改其代码并立即查看更改,而无需重建镜像。

更改问候语app.py并保存。例如,将Hello World!邮件更改为Hello from Docker!

# vi app.py

  1. [root@localhost ~]# cd composetest/
  2. [root@localhost composetest]#
  3. [root@localhost composetest]# ls
  4. app.py docker-compose.yml Dockerfile requirements.txt
  5. [root@localhost composetest]#
  6. [root@localhost composetest]# vi app.py
  7. import time
  8.  
  9. import redis
  10. from flask import Flask
  11.  
  12. app = Flask(__name__)
  13. cache = redis.Redis(host='redis', port=)
  14.  
  15. def get_hit_count():
  16. retries =
  17. while True:
  18. try:
  19. return cache.incr('hits')
  20. except redis.exceptions.ConnectionError as exc:
  21. if retries == :
  22. raise exc
  23. retries -=
  24. time.sleep(0.5)
  25.  
  26. @app.route('/')
  27. def hello():
  28. count = get_hit_count()
  29. return 'Hello from Docker! I have been seen {} times.\n'.format(count)
  30.  
  31. if __name__ == "__main__":
  32. app.run(host="0.0.0.0", debug=True)

刷新浏览器访问

10、尝试其他一些命令

如果要在后台运行服务,可以将-d标志(用于“分离”模式)传递给docker-compose up并使用docker-compose ps以查看当前正在运行的内容:

# docker-compose up -d

# docker-compose ps

  1. [root@localhost composetest]# docker-compose ps
  2. Name Command State Ports
  3. ---------------------------------------------------------------------
  4. composetest_redis_1 docker-entrypoint.sh redis ... Exit
  5. composetest_web_1 python app.py Exit
  6. [root@localhost composetest]#
  7. [root@localhost composetest]# docker-compose up -d
  8. Starting composetest_web_1
  9. Starting composetest_redis_1
  10. [root@localhost composetest]#
  11. [root@localhost composetest]# docker-compose ps
  12. Name Command State Ports
  13. -------------------------------------------------------------------------------------
  14. composetest_redis_1 docker-entrypoint.sh redis ... Up /tcp
  15. composetest_web_1 python app.py Up 0.0.0.0:->/tcp
  16. [root@localhost composetest]#

docker-compose run命令允许您为服务运行一次性命令。例如,要查看web服务可用的环境变量 :

# docker-compose run web env

  1. [root@localhost composetest]# docker-compose run web env
  2. PATH=/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
  3. HOSTNAME=931311c9a4f2
  4. TERM=xterm
  5. LANG=C.UTF-
  6. GPG_KEY=97FC712E4C024BBEA48A61ED3A5CA953F73C700D
  7. PYTHON_VERSION=3.4.
  8. PYTHON_PIP_VERSION=19.0.
  9. HOME=/root

参阅其他可用命令

# docker-compose --help

  1. [root@localhost composetest]# docker-compose --help
  2. Define and run multi-container applications with Docker.
  3.  
  4. Usage:
  5. docker-compose [-f <arg>...] [options] [COMMAND] [ARGS...]
  6. docker-compose -h|--help
  7.  
  8. Options:
  9. -f, --file FILE Specify an alternate compose file (default: docker-compose.yml)
  10. -p, --project-name NAME Specify an alternate project name (default: directory name)
  11. --verbose Show more output
  12. -v, --version Print version and exit
  13. -H, --host HOST Daemon socket to connect to
  14.  
  15. --tls Use TLS; implied by --tlsverify
  16. --tlscacert CA_PATH Trust certs signed only by this CA
  17. --tlscert CLIENT_CERT_PATH Path to TLS certificate file
  18. --tlskey TLS_KEY_PATH Path to TLS key file
  19. --tlsverify Use TLS and verify the remote
  20. --skip-hostname-check Don't check the daemon's hostname against the name specified
  21. in the client certificate (for example if your docker host
  22. is an IP address)
  23.  
  24. Commands:
  25. build Build or rebuild services
  26. bundle Generate a Docker bundle from the Compose file
  27. config Validate and view the compose file
  28. create Create services
  29. down Stop and remove containers, networks, images, and volumes
  30. events Receive real time events from containers
  31. exec Execute a command in a running container
  32. help Get help on a command
  33. kill Kill containers
  34. logs View output from containers
  35. pause Pause services
  36. port Print the public port for a port binding
  37. ps List containers
  38. pull Pulls service images
  39. push Push service images
  40. restart Restart services
  41. rm Remove stopped containers
  42. run Run a one-off command
  43. scale Set number of containers for a service
  44. start Start services
  45. stop Stop services
  46. unpause Unpause services
  47. up Create and start containers
  48. version Show the Docker-Compose version information

停止服务

# docker-compose stop

  1. [root@localhost composetest]# docker-compose ps
  2. Name Command State Ports
  3. -------------------------------------------------------------------------------------
  4. composetest_redis_1 docker-entrypoint.sh redis ... Up /tcp
  5. composetest_web_1 python app.py Up 0.0.0.0:->/tcp
  6. [root@localhost composetest]#
  7. [root@localhost composetest]# docker-compose stop
  8. Stopping composetest_redis_1 ... done
  9. Stopping composetest_web_1 ... done
  10. [root@localhost composetest]#
  11. [root@localhost composetest]# docker-compose ps
  12. Name Command State Ports
  13. ---------------------------------------------------------------------
  14. composetest_redis_1 docker-entrypoint.sh redis ... Exit
  15. composetest_web_1 python app.py Exit
  16. [root@localhost composetest]#

完全删除容器。

# docker-compose down --volumes

--volumes:删除Redis容器使用的数据卷

  1. [root@localhost composetest]# docker-compose down --volumes
  2. Removing composetest_web_run_1 ... done
  3. Removing composetest_redis_1 ... done
  4. Removing composetest_web_1 ... done
  5. Removing network composetest_default
  6. [root@localhost composetest]#
  7. [root@localhost composetest]# docker-compose ps
  8. Name Command State Ports
  9. ------------------------------
  10. [root@localhost composetest]#

参考博客:

https://www.cnblogs.com/ee900222/p/docker_5.html

官方文档:

https://docs.docker.com/compose/gettingstarted/

使用docker compose编排容器的更多相关文章

  1. Docker(二十六)-Docker Compose编排容器

    1. 前言 Docker Compose 是 Docker 容器进行编排的工具,定义和运行多容器的应用,可以一条命令启动多个容器. 使用Compose 基本上分为三步: Dockerfile 定义应用 ...

  2. Docker系列之(五):使用Docker Compose编排容器

    1. 前言 Docker Compose 是 Docker 容器进行编排的工具,定义和运行多容器的应用,可以一条命令启动多个容器. 使用Compose 基本上分为三步: Dockerfile 定义应用 ...

  3. 使用Docker compose编排Laravel应用

    前言 Laravel官方开发环境推荐的是Homestead(其实就是一个封装好的Vagrant box),我感觉这个比较重,于是自己用Docker compose编排了一套开发环境,在这里分享下. 环 ...

  4. Docker Compose之容器编排开发初探

    1.前言 Docker Compose 是 Docker 官方编排(Orchestration)项目之一,负责快速在集群中部署分布式应用. Compose 是一个用于定义和运行多个 Docker 应用 ...

  5. docker compose 编排

    Compose是Docker的服务编排工具,主要用来构建基于Docker的复杂应用,Compose 通过一个配置文件来管理多个Docker容器,非常适合组合使用多个容器进行开发的场景. 说明:Comp ...

  6. Docker Compose编排工具部署lnmp实践及理论(详细)

    目录 一.理论概述 编排 部署 Compose原理 二.使用docker compose 部署lnmp 三.测试 四.总结 一.理论概述 Docker Compose是一个定义及运行多个Docker容 ...

  7. Docker深入浅出系列 | Docker Compose多容器实战

    目录 前期准备 Docker Compose是什么 为什么要用Docker Compose Docker Compose使用场景 Docker Compose安装 Compose Yaml文件结构 C ...

  8. 使用Docker Compose编排Spring Cloud微服务

    文章目录 微服务构建实例 简化Compose的编写 编排高可用的Eureka Server 编排高可用Spring Cloud微服务集群及动态伸缩 微服务项目名称 项目微服务中的角色 microser ...

  9. Docker学习笔记之使用 Docker Compose 管理容器

    0x00 概述 通过之前的介绍,我们已经基本掌握了构建.运行容器的方法,但这还远远不够,由于 Docker 采用轻量级容器的设计,每个容器一般只运行一个软件,而目前绝大多数应用系统都绝不是一个软件所能 ...

随机推荐

  1. MySQL自增序列-亲试ok

    #1.创建sequence表,公共的 DROP TABLE IF EXISTS sequence; CREATE TABLE sequence (      name VARCHAR(30) NOT ...

  2. 批量压缩 css js 文件 包含多个文件 自动识别

    注意事项  css 注释压缩不会造成影响      因为是块注释     当然也可以选择去注释压缩 js 带注释压缩  要注意注意 注意  //行注释会造成 压缩后的代码在一行 导致注释后的代码都失效 ...

  3. CentOS 7上安装Pure-FTPd

    # 安装 yum install epel-release yum install pure-ftpd 位置文件位于/etc/pure-ftpd/pure-ftpd.conf # 修改配置文件 # 注 ...

  4. 微信小程序silk格式转码成mp3格式

    最近小程序项目需要录制语音并上传到服务器,经过查资料了解 目前微信小程序录音的文件后缀名是silk,因此需要转换. 经过查资料了解,参考一下的地址 https://github.com/kn007/s ...

  5. Spring Boot + Jpa + Thymeleaf 增删改查示例

    快速上手 配置文件 pom 包配置 pom 包里面添加 Jpa 和 Thymeleaf 的相关包引用 <dependency> <groupId>org.springframe ...

  6. java多线程之yield,join,wait,sleep的区别

    Java多线程之yield,join,wait,sleep的区别 Java多线程中,经常会遇到yield,join,wait和sleep方法.容易混淆他们的功能及作用.自己仔细研究了下,他们主要的区别 ...

  7. eureka 服务注册与发现

    1.创建父工程来管理依赖包 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http:/ ...

  8. TestLink测试管理工具的使用说明

    1. 创建项目: 主页左边的列表栏有 “Test Project management”的菜单,子菜单中有 “ create new test project”,通过它可以创建新的测试项目. 同时,菜 ...

  9. spring(一、原理、IOC、AOP、依赖注入)

    1.spring原理 内部最核心的就是IOC了,动态注入,让一个对象的创建不用new了,可以自动的生产,这其实就是利用java里的反射,反射其实就是在运行时动态的去创建.调用对象,Spring就是在运 ...

  10. input[type='file']默认样式

    <input type="file" name="" id="" value="" /> 当input的ty ...