- 浏览: 2486691 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
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 1609I am still keep notes my tech n ... -
Stop Update Here
2020-04-28 09:00 260I will stop update here, and mo ... -
NodeJS12 and Zlib
2020-04-01 07:44 430NodeJS12 and Zlib It works as ... -
Docker Swarm 2020(2)Docker Swarm and Portainer
2020-03-31 23:18 310Docker Swarm 2020(2)Docker Swar ... -
Docker Swarm 2020(1)Simply Install and Use Swarm
2020-03-31 07:58 321Docker Swarm 2020(1)Simply Inst ... -
Traefik 2020(1)Introduction and Installation
2020-03-29 13:52 291Traefik 2020(1)Introduction and ... -
Portainer 2020(4)Deploy Nginx and Others
2020-03-20 12:06 378Portainer 2020(4)Deploy Nginx a ... -
Private Registry 2020(1)No auth in registry Nginx AUTH for UI
2020-03-18 00:56 373Private Registry 2020(1)No auth ... -
VPN Server 2020(2)Docker on CentOS in Ubuntu
2020-03-02 08:04 397VPN Server 2020(2)Docker on Cen ... -
Buffer in NodeJS 12 and NodeJS 8
2020-02-25 06:43 334Buffer in NodeJS 12 and NodeJS ... -
NodeJS ENV Similar to JENV and PyENV
2020-02-25 05:14 415NodeJS ENV Similar to JENV and ... -
Prometheus HA 2020(3)AlertManager Cluster
2020-02-24 01:47 359Prometheus HA 2020(3)AlertManag ... -
Serverless with NodeJS and TencentCloud 2020(5)CRON and Settings
2020-02-24 01:46 292Serverless with NodeJS and Tenc ... -
GraphQL 2019(3)Connect to MySQL
2020-02-24 01:48 208GraphQL 2019(3)Connect to MySQL ... -
GraphQL 2019(2)GraphQL and Deploy to Tencent Cloud
2020-02-24 01:48 390GraphQL 2019(2)GraphQL and Depl ... -
GraphQL 2019(1)Apollo Basic
2020-02-19 01:36 275GraphQL 2019(1)Apollo Basic Cl ... -
Serverless with NodeJS and TencentCloud 2020(4)Multiple Handlers and Running wit
2020-02-19 01:19 264Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(3)Build Tree and Traverse Tree
2020-02-19 01:19 259Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(2)Trigger SCF in SCF
2020-02-19 01:18 252Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(1)Running with Component
2020-02-19 01:17 235Serverless with NodeJS and Tenc ...
相关推荐
DockerCompose(博客所需资源)
基于Docker Compose构建的MySQL MHA集群
一键离线安装docker、docker-compose
基于Docker Compose和Swarm的Docker化之路
docker compose部署redis集群,三主三从,并且外网可以访问,另外还可以从gitee上获取此文件,gitee上除了Redis之外还会陆续提供其他docker部署的文件,https://gitee.com/korov/Docker.git
适用于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 。自动运行...
Docker Compose version v2.5.0 docker-compose install success (你也可以自行去github上面下载最新的docker-compose的二进制包,但是这将浪费你半个小时的时间,然后还要自己安装。所以1.9元交个朋友)
docker-compose 容器部署 mqtt 配置文件
Docker-Compose项目是Docker官方的开源项目,负责实现对Docker容器集群的快速编排。 Docker-Compose将所管理的容器分为三层,分别是工程(project),服务(service)以及容器(container)。Docker-Compose运行目录...
1.先运行 createFile.py 输入宿主机IP地址,输入redis密码 2.按照控制台输出执行docker-compose up -d 启动命令 3.启动成功后执行加入集群命令即可
docker-compose安装包(三个版本)
解决不支持docker-compose命令的问题,而从gihub下载缓慢,适用于x87_64的linux系统,
docker离线安装所需的所有依赖包和docker本身的包,还有docker-compose工具的安装包,使用方法直接去这篇博客:https://cuichongxin.blog.csdn.net/article/details/118033211
Free。Docker-compose-2.4.1安装包:Linux。
安装maven环境,通过docker命令打包镜像,然后编写docker-compose编排文件,部署springboot工程
这个Docker Compose 文件定义了一个包含Zookeeper和三个Kafka节点的服务集群。通过指定镜像、端口映射、环境变量和依赖关系等配置,实现了Zookeeper和Kafka的快速部署和集成。同时,在定义了一个名为"mynetwork"的...
docker compose v2.23.0版本 适用于ARM主机,如树莓派等
java运维 ,微服务平台使用Docker compose部署案例,并附文件代码及注意事项。
docker-compose-2.20.2安装包
网上关于aarch64版本的docker-compose非常的少,比较难找,在这里希望这里可以帮到大家。