PrerequisitesCompose is a tool for orchestrating Docker containers. It is a powerful tool for integrating and publishing Docker applications. It can define and run multi-container applications. In Compose, you can use YAML files to configure your application services. Then, with just one simple command, all the services you configured are created and started. Docker-compose is based on Docker, so we need to install Docker before we can use Docker-compose. Using Compose basically involves the following three steps: Define your application environment in Dockerfile, which can be multiple docker applications. Reference URL: Docker installation
sudo yum remove docker \ docker-client \ docker-client-latest \ docker-common \ docker-latest \ docker-latest-logrotate \ docker-logrotate \ docker-engine
sudo yum install -y yum-utils device-mapper-persistent-data lvm2 sudo yum-config-manager \ --add-repo \ http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo sudo yum install docker-ce docker-ce-cli containerd.io
sudo systemctl start docker
yum install https://download.docker.com/linux/fedora/30/x86_64/stable/Packages/containerd.io-1.2.6-3.3.fc30.x86_64.rpm
docker --version
docker-compose installationThe official website download address may be slow, it is recommended to use the following
curl -L https://get.daocloud.io/docker/compose/releases/download/1.26.2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose version
Getting Started with Docker ComposeGenerate mysql and redis containers through docker-compose 1. Create a project directory and enter $ mkdir composetest $ cd composetest 2. Create a The specific contents of the file are as follows: version: "3.0" services: mysqldb: image:mysql:5.7.19 container_name: mysql ports: - "3306:3306" volumes: - /root/mysql/conf:/etc/mysql/conf.d - /root/mysql/logs:/logs - /root/mysql/data:/var/lib/mysql environment: MYSQL_ROOT_PASSWORD: root networks: -ems depends_on: - redis redis: image: redis:4.0.14 container_name: redis ports: - "6379:6379" networks: -ems volumes: - /root/redis/data:/data command: redis-server networks: ems: 3. Start Start in current folder
The output log is as follows Check whether the container in Docker is availableCheck whether the container is generated Test whether the redis container is available Test whether the mysql container is available
Summarize1. The docker-compose command cannot be executed because of a permission issue. We need to open permissions and execute the following command chmod +x /usr/local/bin/docker-compose 2. During the study period, we can use docker-compose in the virtual machine to build our basic hardware facilities, which is very convenient and saves a lot of time in configuring the environment and installing basic services. 3. Docker-compose still needs to be learned Reference URL:
This is the end of this article about getting started with docker compose helloworld. For more information about getting started with docker compose helloworld, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Master-slave synchronization configuration of Mysql database
>>: Solution to span width not being determined in Firefox or IE
"Grand" are probably the two words that ...
This article example shares the specific code of ...
Preface What is the role of an agent? - Multiple ...
Today, let’s get straight to the point and talk a...
Copy code The code is as follows: <!DOCTYPE ht...
Table of contents 1 What is function currying? 2 ...
Table of contents 1. Overview 2. Define a simple ...
Concept introduction : 1. px (pixel): It is a vir...
Table of contents 1. Use 2. Solve the problem of ...
Table of contents 1. Introduction 2. About vue-si...
Table of contents 1. Background 2. Table creation...
This article shares with you how to query the sta...
This article shares with you the graphic tutorial...
1.docker search mysql查看mysql版本 2. docker pull mys...
This article example shares the specific code of ...