In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "how to install and apply Docker Compose in Ubuntu". In daily operation, I believe many people have doubts about how to install and apply Docker Compose in Ubuntu. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts about "how to install and apply Docker Compose in Ubuntu". Next, please follow the editor to study!
Docker Compose is a Docker tool for defining and running complex applications. An application that uses Docker containers, usually consisting of multiple containers. Using Docker Compose, you no longer need to use the shell script to start the container.
Install Docker
We need to install Docker to install Docker Compose. First add the public key to the official Docker repository.
$curl-fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add-
Next, add the Docker repository to the apt source list:
$sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release-cs) stable"
Update the package database and install Docker using apt
$sudo apt-get update$ sudo apt install docker-ce
At the end of the installation process, the Docker daemon should have been started and set to boot automatically. We can check its status with the following command:
$sudo systemctl status docker-- ● docker.service-Docker Application Container EngineLoaded: loaded (/ lib/systemd/system/docker.service; enabled; vendor preset: enabled) Active: active (running) install Docker Compose
Now you can install Docker Compose. Download the current version by executing the following command.
# curl-L https://github.com/docker/compose/releases/download/1.14.0/docker-compose-`uname-s`-`uname-m` > / usr/local/bin/docker-compose
Add execute permissions to the binaries:
# chmod + x / usr/local/bin/docker-compose
Check the Docker Compose version:
$docker-compose-v
The output should be as follows:
Docker-compose version 1.14.0, build c7bdf9e test Docker Compose
Docker Hub contains a Hello World image for demonstration, which can be used to illustrate the configuration required to use Docker Compose to run a container.
Create and open a directory:
$mkdir hello-world $cd hello-world
Create a new YAML file:
$$EDITOR docker-compose.yml
Paste the following in the file:
Unixmen-compose-test:image: hello-world
Note: the first line is part of the container name. Save and exit.
Run the container
Next, execute the following command in the hello-world directory:
$sudo docker-compose up
If everything is all right, the Compose output should be as follows:
Pulling unixmen-compose-test (hello-world:latest)... latest: Pulling from library/hello-worldb04784fba78d: Pull completeDigest: sha256:f3b3b28a45160805bb16542c9531888519430e9e6d6ffc09d72261b0d26ff74fStatus: Downloaded newer image for hello-world:latestCreating helloworld_unixmen-compose-test_1... Creating helloworld_unixmen-compose-test_1... DoneAttaching to helloworld_unixmen-compose-test_1unixmen-compose-test_1 | unixmen-compose-test_1 | Hello from DockersunixmencomposeMushroom 1 | This message shows that your installation appears to be working correctly.unixmen-compose-test_1 | unixmen-compose-test_1 | To generate this message, Docker took the following steps:unixmen-compose-test_1 | 1\. The Docker client contacted the Docker daemon.unixmen-compose-test_1 | 2\. The Docker daemon pulled the "hello-world" image from the Docker Hub.unixmen-compose-test_1 | 3. The Docker daemon created a new container from that image which runs theunixmen-compose-test_1 | executable that produces the output you are currently reading.unixmen-compose-test_1 | 4\. The Docker daemon streamed that output to the Docker client, which sent itunixmen-compose-test_1 | to your terminal.unixmen-compose-test_1 | unixmen-compose-test_1 | To try something more ambitious, you can run an Ubuntu container with:unixmen-compose-test_1 | $docker run-it ubuntu bashunixmen-compose-test_1 | unixmen-compose-test_1 | Share images, automate workflows And more with a free Docker ID:unixmen-compose-test_1 | https://cloud.docker.com/unixmen-compose-test_1 | unixmen-compose-test_1 | For more examples and ideas, visit:unixmen-compose-test_1 | https://docs.docker.com/engine/userguide/unixmen-compose-test_1 | helloworld_unixmen-compose-test_1 exited with code 0 Docker
The container can only be run while the command is still active, so the container will stop running when the test finishes running.
At this point, the study on "how to install and apply Docker Compose in Ubuntu" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.