What is Docker-compose? (Personal memorandum)

What is Docker Compose?

A tool for defining and running multi-container docker applications. It is often used to set up a development environment or an automated test execution environment. As a usage, by describing the definitions of web server, DB server, cache server, etc. in one yml file, you can start all the containers required for application execution based on the yml file. yml is a format for expressing structured data, and it can be described intuitively even if you have never used yml. You can understand the structure by looking at the file.

Steps to run Conpose

1 Prepare ** Dockerfile ** or ** image to use ** on Docker Hub etc. 2 Define ** docker-compose.yml ** Write the startup settings for each container. This is like specifying an image name and various flags with the docker run command. 3 Run ** docker-compose up ** Specify docker-compose up in the directory where docker-compose is located. However, if it is left as it is, it will be executed in the foreground, so it is often executed by detaching with the -d option. When executed, each container will be executed according to the definition of docker-compose.yml.

docker-compose.yml


version: '3'                -#docker-Compose file format version
services:
  web:                      -#Service name, any name can be given
    build: .                -#docker-compose.The build context is the same directory as yml. So you need to create a dockerfile for your web service in the same directory as your yml file
    ports:                  -#Indicates the port to be exposed to the outside of the container and the port to be mapped.
    - "5000:5000"
    volumes:  
    - .:/code               -#docker with bind mount-compose.The directory where yml exists is the container/Mounted in the code directory.
    - logvolume01:/var/log  -#The volume of logvolume01 defined in volumes is the volume of the web service container./var/Mounted on log.
    links:
    - redis                 -#I'm setting up a link from a web service to a redis service
    redis:
    image: redis            -#The redis service simply launches a container using a redis image.
volumes:
  logvolume01               -#If you want to mount a named volume, you need to define it in volumes.
Expressly{}However, it is not necessary to write it. When writing settings such as driver to be used for volume,
You can continue to write the settings under the volume name, but if you simply use the default volume, no settings are required.

Check docker-compose

% docker-compose -v
docker-compose version 1.26.2, build eefe0d31

If downloaded, the docker-compose version will be displayed.

Recommended Posts

What is Docker-compose? (Personal memorandum)
What is `docker-compose up`?
[Memorandum] What is an error?
What is Cubby
What is Docker?
What is null? ]
What is java
What is Keycloak
What is maven?
What is Jackson?
What is Docker
What is self
What is ArgumentMatcher?
What is IM-Juggling?
What is params
What is SLF4J?
What is Facade? ??
What is Gradle?
What is POJO
What is Java
What is centOS
What is programming?
What is before_action?
What is Docker
What is Tomcat
Django development environment construction using Docker-compose (personal memorandum)
What is Maven Assembly?
What is a constructor?
What is vue cli
What is an interface?
Docker Machine (personal memorandum)
What is Ruby's self?
What is hard coding?
What is a stream
What is Ruby's attr_accessor?
What is Java Encapsulation?
What is instance control?
What is an initializer?
What is Spring Tools 4
What is an operator?
What is object orientation?
What is Guava's @VisibleForTesting?
What is MVC model?
What is an annotation?
What is Java technology?
What is Java API-java
What is @ (instance variable)?
What is JPA Auditing?
[Swift] What is dismiss?
[Java] What is flatMap?
What is a Servlet?
What is web development?
[Java] What is JavaBeans?
[Android] What is Context? ??
[Java] What is ArrayList?
Docker network (personal memorandum)
[Ruby] What is true?
What is object-oriented after all?
What is HttpSession session = request.getSession ();
What is docker run -it?
What is Java Assertion? Summary.