In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Docker Compose is a Docker tool for defining and running complex applications. Using Docker Compose no longer requires the use of shell scripts to start the container. (configured via docker-compose.yml)
Installation of Docker Compose
Github source
Sudo curl-L https://github.com/docker/compose/releases/download/1.22.0/docker-compose-`uname-s`-`uname-m`-o / usr/local/bin/docker-compose# add executable permissions to docker-compose sudo chmod + x / usr/local/bin/docker-compose
Daocloud source
Curl-L https://get.daocloud.io/docker/compose/releases/download/1.22.0/docker-compose-`uname-s`-`uname-m` > / usr/local/bin/docker-compose# add executable permissions to docker-compose sudo chmod + x / usr/local/bin/docker-compose
Uninstall Docker Compose
Sudo rm / usr/local/bin/docker-compose
View the version of Docker Compose
Docker-compose-version
Configure Dockerfile
# specify the basic image and customize the FROM java:8# maintainer information MAINTAINER zhouzhaodong # set the working directory WORKDIR / apps/demo# to add demo-0.0.1-SNAPSHOT.jar to the container ADD demo-0.0.1-SNAPSHOT.jar demo-1.0.0.jar#bash execution, so that demo-1.0.0.jar can access # RUN to create a new layer, execute these commands on it, and modify the commit layer after execution To form a new mirror image. RUN bash-c "touch / demo-1.0.0.jar" # states that the runtime container provides a service port, which is just a declaration, and the service EXPOSE 808 will not open this port at run time because of this declaration. EXPOSE 808 specifies the container launcher and parameters "" ENTRYPOINT ["java", "- jar", "demo-1.0.0.jar"]
Configure the docker-compose.yml file
# version version: '3.0'services: demo: # build is used to specify the file path where the Dockerfile is located. Build:. # Mapping port ports:-"8080 Dockerfile" volumes: # specify a file directory to store container data. # $PWD indicates the current path-$PWD/data:/var/lib/log
Common commands of docker-compose
Build: # build image docker-compose build without cache-- no-cache;up: # build and launch container docker-compose up-ddown: # delete all containers, image docker-compose downrestart: # restart container docker-compose build; docker-compose down; docker-compose up-d
Run the docker-compose command to build and run the image
First of all, create a new folder in the host to store the Dockerfile,docker-compose.yml we created earlier and the jar package we packed. First go to this directory and run the down command to delete all previously created images. Run the build command to generate an image. Run the up command to start the container. Visit the ip+ port number and you can see our program.
The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.
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.