In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article focuses on "how to use Docker Compose in Ubuntu16.04". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn how to use Docker Compose in Ubuntu16.04.
Docker Compose is a tool for creating and launching Docker applications by using a single command, running multi-container Docker applications, and configuring application services using Docker Compose
Docker Compose is suitable for many different projects, such as:
Development: with the Compose command line tool, we can create an isolated (but interactive) environment to host applications under development. By using Compose files, developers can record and configure service dependencies for all applications.
Automated testing: this use case requires a test run environment. Compose provides a convenient way to manage the isolated test environment of the test suite. The complete environment is defined in the Compose file.
To 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" updates the package database and installs Docker using apt
Sudo apt-get update$ sudo apt install docker-ce after the installation process ends, 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 Engine Loaded: loaded (/ lib/systemd/system/docker.service; enabled; vendor preset: enabled) Active: active (running) install Docker Compose you can now 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 execution permissions for binary files:
# chmod + x / usr/local/bin/docker-compose check Docker Compose version:
The output of $docker-compose-v should be as follows:
Docker-compose version 1.14.0, the build c7bdf9e test Docker ComposeDocker Hub contains a Hello World image for demonstration, which can be used to illustrate the configuration required to run a container using Docker Compose.
Create and open a directory:
$mkdir hello-world$ cd hello-world create a new YAML file:
$EDITOR docker-compose.yml pastes the following in the file:
Unixmen-compose-test: image: hello-world* Note: the first line is part of the container name. *
Save and exit.
To run the container, next, execute the following command in the hello-world directory:
$sudo docker-compose up if everything is normal, 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 0Docker container can only be run when the command (LCTT translation) is still active So when the test finishes running, the container stops running.
At this point, I believe you have a deeper understanding of "how to use Docker Compose in Ubuntu16.04". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.