- 浏览: 2542351 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
Docker Compose 2020(1)Installation and Basic
Latest Docker Compose version VS Docker version
https://docs.docker.com/compose/compose-file/
On my server, check the docker version
> docker --version
Docker version 19.03.6, build 369ce74a3c
Open my docker 2375 ports if we need
> sudo vi /usr/lib/systemd/system/docker.service
ExecStart=/usr/bin/dockerd -H tcp://10.132.156.80:2375 -H unix:///var/run/docker.sock -H fd:// --containerd=/run/containerd/containerd.sock
> sudo systemctl daemon-reload
> sudo systemctl restart docker
I use portainer to clean up all the images and containers and other resources.
My testing server even more up to date
> docker --version
Docker version 19.03.8, build afacb8b
If we do not have docker installed, we may use this script
> curl -sSL https://get.docker.com/ | sh
Verify if my version is cool
> docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
Check the latest version for compose https://github.com/docker/compose/releases/
Current latest version 1.25.4
> sudo curl -L https://github.com/docker/compose/releases/download/1.25.4/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
> sudo chmod +x /usr/local/bin/docker-compose
Check version
> docker-compose --version
docker-compose version 1.25.4, build 8d51620a
Do a simple Sample
> mkdir compose-sample
> cd compose-sample/
> mkdir src
> mkdir docker
Python source
> vi src/app.py
from flask import Flask
from redis import Redis
app = Flask(__name__)
redis = Redis(host='redis', port=6379)
@app.route('/')
def hello():
count = redis.incr('hits')
return 'hello, Carl. I see you {} times.\n'.format(count)
if __name__ == "__main__":
app.run(host="0.0.0.0", debug=True)
A simple flask server increase the redis count.
Running requirement file
> vi src/requirements.txt
flask
redis
Prepare the Docker Image
> mkdir docker/web
> vi docker/web/Dockerfile
FROM python:3.4
ADD . /docker
ADD ../../src /src
WORKDIR /src
RUN pip install -r requirements.txt
CMD ["python", "app.py"]
../../src is wrong in the Dockerfile, we can fix that later.
> vi docker/docker-compose.yml
version: '3'
services:
web:
build: ./web/
ports:
- "5000:5000"
redis:
image: "redis:3.0.7"
Change to use volumes
version: '3'
services:
web:
build: ./web/
ports:
- "5000:5000"
volumes:
- ../src:/src
redis:
image: "redis:3.0.7"
> cat docker/web/Dockerfile
FROM python:3.4
WORKDIR /src
RUN pip install -r requirements.txt
CMD ["python", "app.py"]
Try to run that
> docker-compose up
Not working, change to this
version: '3'
services:
web:
build: ./web/
ports:
- "5000:5000"
volumes:
- /home/carl/work/compose-sample/src:/src
redis:
image: "redis:3.0.7"
Check logging
> docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f74e3bacc623 redis:3.0.7 "docker-entrypoint.s…" 8 seconds ago Up 6 seconds 6379/tcp docker_redis_1
85dfcacda306 docker_web "python3" 8 seconds ago Exited (0) 6 seconds ago docker_web_1
Try to start the web and check why, it seems the src is not there at all.
> docker run -it --name docker_web1 docker_web:latest /bin/bash
Adjust the directory from the example as follow:
web/Dockerfile
web/src/app.py
web/src/requirements.txt
docker-compose.yml
> docker-compose up
Visit the page, it works pretty well.
http://rancher-home:5000/
References:
https://beginor.github.io/2017/06/08/use-compose-instead-of-run.html
https://docs.docker.com/compose/compose-file/
https://blog.csdn.net/pushiqiang/article/details/78682323
Latest Docker Compose version VS Docker version
https://docs.docker.com/compose/compose-file/
On my server, check the docker version
> docker --version
Docker version 19.03.6, build 369ce74a3c
Open my docker 2375 ports if we need
> sudo vi /usr/lib/systemd/system/docker.service
ExecStart=/usr/bin/dockerd -H tcp://10.132.156.80:2375 -H unix:///var/run/docker.sock -H fd:// --containerd=/run/containerd/containerd.sock
> sudo systemctl daemon-reload
> sudo systemctl restart docker
I use portainer to clean up all the images and containers and other resources.
My testing server even more up to date
> docker --version
Docker version 19.03.8, build afacb8b
If we do not have docker installed, we may use this script
> curl -sSL https://get.docker.com/ | sh
Verify if my version is cool
> docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
Check the latest version for compose https://github.com/docker/compose/releases/
Current latest version 1.25.4
> sudo curl -L https://github.com/docker/compose/releases/download/1.25.4/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
> sudo chmod +x /usr/local/bin/docker-compose
Check version
> docker-compose --version
docker-compose version 1.25.4, build 8d51620a
Do a simple Sample
> mkdir compose-sample
> cd compose-sample/
> mkdir src
> mkdir docker
Python source
> vi src/app.py
from flask import Flask
from redis import Redis
app = Flask(__name__)
redis = Redis(host='redis', port=6379)
@app.route('/')
def hello():
count = redis.incr('hits')
return 'hello, Carl. I see you {} times.\n'.format(count)
if __name__ == "__main__":
app.run(host="0.0.0.0", debug=True)
A simple flask server increase the redis count.
Running requirement file
> vi src/requirements.txt
flask
redis
Prepare the Docker Image
> mkdir docker/web
> vi docker/web/Dockerfile
FROM python:3.4
ADD . /docker
ADD ../../src /src
WORKDIR /src
RUN pip install -r requirements.txt
CMD ["python", "app.py"]
../../src is wrong in the Dockerfile, we can fix that later.
> vi docker/docker-compose.yml
version: '3'
services:
web:
build: ./web/
ports:
- "5000:5000"
redis:
image: "redis:3.0.7"
Change to use volumes
version: '3'
services:
web:
build: ./web/
ports:
- "5000:5000"
volumes:
- ../src:/src
redis:
image: "redis:3.0.7"
> cat docker/web/Dockerfile
FROM python:3.4
WORKDIR /src
RUN pip install -r requirements.txt
CMD ["python", "app.py"]
Try to run that
> docker-compose up
Not working, change to this
version: '3'
services:
web:
build: ./web/
ports:
- "5000:5000"
volumes:
- /home/carl/work/compose-sample/src:/src
redis:
image: "redis:3.0.7"
Check logging
> docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f74e3bacc623 redis:3.0.7 "docker-entrypoint.s…" 8 seconds ago Up 6 seconds 6379/tcp docker_redis_1
85dfcacda306 docker_web "python3" 8 seconds ago Exited (0) 6 seconds ago docker_web_1
Try to start the web and check why, it seems the src is not there at all.
> docker run -it --name docker_web1 docker_web:latest /bin/bash
Adjust the directory from the example as follow:
web/Dockerfile
web/src/app.py
web/src/requirements.txt
docker-compose.yml
> docker-compose up
Visit the page, it works pretty well.
http://rancher-home:5000/
References:
https://beginor.github.io/2017/06/08/use-compose-instead-of-run.html
https://docs.docker.com/compose/compose-file/
https://blog.csdn.net/pushiqiang/article/details/78682323
发表评论
-
Update Site will come soon
2021-06-02 04:10 1672I am still keep notes my tech n ... -
Stop Update Here
2020-04-28 09:00 310I will stop update here, and mo ... -
NodeJS12 and Zlib
2020-04-01 07:44 468NodeJS12 and Zlib It works as ... -
Docker Swarm 2020(2)Docker Swarm and Portainer
2020-03-31 23:18 361Docker Swarm 2020(2)Docker Swar ... -
Docker Swarm 2020(1)Simply Install and Use Swarm
2020-03-31 07:58 364Docker Swarm 2020(1)Simply Inst ... -
Traefik 2020(1)Introduction and Installation
2020-03-29 13:52 330Traefik 2020(1)Introduction and ... -
Portainer 2020(4)Deploy Nginx and Others
2020-03-20 12:06 424Portainer 2020(4)Deploy Nginx a ... -
Private Registry 2020(1)No auth in registry Nginx AUTH for UI
2020-03-18 00:56 428Private Registry 2020(1)No auth ... -
VPN Server 2020(2)Docker on CentOS in Ubuntu
2020-03-02 08:04 445VPN Server 2020(2)Docker on Cen ... -
Buffer in NodeJS 12 and NodeJS 8
2020-02-25 06:43 377Buffer in NodeJS 12 and NodeJS ... -
NodeJS ENV Similar to JENV and PyENV
2020-02-25 05:14 468NodeJS ENV Similar to JENV and ... -
Prometheus HA 2020(3)AlertManager Cluster
2020-02-24 01:47 413Prometheus HA 2020(3)AlertManag ... -
Serverless with NodeJS and TencentCloud 2020(5)CRON and Settings
2020-02-24 01:46 331Serverless with NodeJS and Tenc ... -
GraphQL 2019(3)Connect to MySQL
2020-02-24 01:48 243GraphQL 2019(3)Connect to MySQL ... -
GraphQL 2019(2)GraphQL and Deploy to Tencent Cloud
2020-02-24 01:48 444GraphQL 2019(2)GraphQL and Depl ... -
GraphQL 2019(1)Apollo Basic
2020-02-19 01:36 320GraphQL 2019(1)Apollo Basic Cl ... -
Serverless with NodeJS and TencentCloud 2020(4)Multiple Handlers and Running wit
2020-02-19 01:19 307Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(3)Build Tree and Traverse Tree
2020-02-19 01:19 310Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(2)Trigger SCF in SCF
2020-02-19 01:18 285Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(1)Running with Component
2020-02-19 01:17 303Serverless with NodeJS and Tenc ...
相关推荐
在IT行业中,Docker和Docker Compose是两个极为重要的工具,它们在容器化应用程序部署和管理方面扮演着核心角色。本文将详细讲解如何通过二进制方式安装Docker 19.03.14及其配套的Docker Compose,并讨论它们的主要...
Docker-Compose项目是Docker官方的开源项目,负责实现对Docker容器集群的快速编排。 Docker-Compose将所管理的容器分为三层,分别是工程(project),服务(service)以及容器(container)。Docker-Compose运行目录...
DockerCompose(博客所需资源)
1. Docker Compose V1.29.2:这是较旧的一个版本,支持YAML文件的v2格式。它提供了一系列的命令行选项,如`docker-compose up`用于启动所有服务,`docker-compose down`用于停止并删除服务及关联的网络等。此外,此...
【标题】"docker-compose_install.tar.gz" 是一个针对 CentOS 7 的 Docker 和 Docker Compose 的离线一键部署包。这个压缩文件提供了在没有网络连接或者网络环境受限的情况下,安装 Docker 和 Docker Compose 的便捷...
适用于Linux的Docker version 20.10.12, build e91ed57和Docker Compose version v2.2.2离线自动安装包。unzip解压后,进入解压出来的docker_x86_64目录,运行sudo bash install.sh docker-20.10.12.tgz 。自动运行...
在IT行业中,Docker和Docker Compose是两个极为重要的工具,尤其对于开发、测试和部署微服务架构的应用程序来说。Docker是一个开源的应用容器引擎,它允许开发者打包他们的应用及其依赖包到一个可移植的容器中,然后...
1. `docker-compose`:这是Docker Compose的可执行文件,用于执行各种管理命令。 2. `libcrypto.1.1.dylib` 和 `libssl.1.1.dylib`:这两个是OpenSSL库,用于提供加密和安全通信功能,是Docker Compose依赖的库。 3....
Docker Compose version v2.5.0 docker-compose install success (你也可以自行去github上面下载最新的docker-compose的二进制包,但是这将浪费你半个小时的时间,然后还要自己安装。所以1.9元交个朋友)
1)解压后将docker-compose上传至服务器/usr/bin目录下 2)chmod + 755 docker-compose 3)docker-compose可以直接运行了
docker版本26.1.2,docker-compose版本v2.11.0。 1.把docker_compose_install-new文件夹放在任意路径; 2.chmod -R 777 install.sh 3.执行./install.sh 兼容:CentOS7.6、麒麟V10服务器版。
在IT行业中,Docker和Docker Compose是两个非常重要的工具,它们被广泛应用于容器化应用程序的部署和管理。Ubuntu是流行的Linux操作系统,它为Docker提供了良好的支持。本资源包提供的是Ubuntu 20.10.12版本上的...
基于Docker Compose构建的MySQL MHA集群
1. **服务定义**:在`docker-compose.yml`文件中,你可以定义一系列的服务,每个服务都包含了容器镜像、端口映射、环境变量、数据卷等信息。 2. **网络管理**:Compose可以自动创建和管理网络,让服务之间能够相互...
一键离线安装docker、docker-compose
docker compose部署redis集群,三主三从,并且外网可以访问,另外还可以从gitee上获取此文件,gitee上除了Redis之外还会陆续提供其他docker部署的文件,https://gitee.com/korov/Docker.git
Docker-Compose项目是Docker官方的开源项目,负责实现对Docker容器集群的快速编排。 Docker Compose将所管理的容器分为三层,分别是工程(project),服务(service)以及容器 (container)。Docker-Compose运行...
1. **下载Docker Compose**: 首先,你需要访问Docker的官方GitHub仓库(https://github.com/docker/compose/releases)来获取最新或特定版本的Docker Compose二进制文件。通常,这个文件名为`docker-compose-Linux-...