People using docker Try using docker-compose


This article is a memorandum based on the following Udemy courses. Docker course taught by US AI developers from scratch

When it's good to use docker-compose

--When the docker run command gets long --When starting multiple containers at once


Check if docker-compose is included. (It was included when Docker was installed, but just in case)

$ $ docker-compose --version
docker-compose version 1.27.4, build 40524192

If you do not get the version information, please install it. Install Docker Compose

Prepare the build context. The configuration this time is as follows.


 ∟ docker-compose.yml
 ∟ Dockerfile

Write the docker run command in docker-copose.yml

docker command example

$ docker build .
$ docker run -d -it -v /Users/yukokanai/work/docker/project-name:/project-name -p 8888:8888 {image} bash
$ docker exec -it {Container name}

Write this in docker-compose.yml


version: '3'

    build: .           #Implemented from build
    ports:             #-p Port forwarding
      - '8888:8888'
    volumes:           #-v host directory(.)The container directory(/project-name)Mount on
      - '.:/project-name'
    tty: true          #-Allocate t tty.
    stdin_open: true   #-Open i STDIN.


#Go to build context
$ cd project-name

#If there is no image, build and run(I want to use it as a web server-d)
$ docker-compose up -d
#If you do not want to use the cache image, do as follows
#$ docker-compose up --build -d

#Go inside the container(web is the service name written in yml)
$ docker-compose exec web bash


$ docker-compose down

When creating multiple containers



version: '3'


    build: .
      - '3000:3000'
      - '.:/my_product-register'
      - 'POSTGRES_PASSWORD=postgres'
    tty: true
    stdin_open: true
      - db
      - db

    image: postgres
      - 'db-data:/var/lib/postgresql/data'
      - 'POSTGRES_PASSWORD=postgres'

Recommended Posts

People using docker Try using docker-compose
try docker-compose
Try using Redmine on Mac docker
Try using Maven
Try using powermock-mockito2-2.0.2
Try using GraalVM
Try using jmockit 1.48
Try using sql-migrate
Try using Kong + Konga with Docker Compose.
Try using another Servlet container Jetty with Docker
Try using Axon Framework
Try using JobScheduler's REST-API
Try using java.lang.Math methods
Try using PowerMock's WhiteBox
Try WildFly with Docker
Docker Compact Manual (3: docker-compose)
Try using Talend Part 1
Try using F # list
Try using each_with_index method
Try using Spring JDBC
Try to build a Java development environment using Docker
Command to try using Docker for the time being
Try using RocksDB in Java
Try using GloVe with Deeplearning4j
Try using view_component with rails
Docker, docker-compose for server-side Kotlin
Try scraping using java [Notes]
Try using Cocoa from Ruby
Try using letter_opener_web for inquiries
Try Docker on Windows 10 Home
[Swift] Try using Collection View
Try using IntelliJ IDEA once
Try Hello World using plain Java on a Docker container
Using Docker from Java Gradle
Install docker, docker-compose for debin10
Try using gRPC in Ruby
[Rails] Try using Faraday middleware
[Processing] Try using GT Force.
[Programming Encyclopedia] §2 Try using Ruby
multi-project docker build using jib
Using PlantUml with Honkit [Docker]
Try running cloudera manager with docker
Try using Redis with Java (jar)
Create Laravel environment with Docker (docker-compose)
[Java] Try to implement using generics
Try Docker on Windows Home (September 2020)
Try using IBM Java method tracing
Using Docker on Windows10 Home WSL2
Easily try C # 9 (.NET 5) on Docker
Use cuda11.0 with pytorch using Docker
How to build CloudStack using Docker
Try using Hyperledger Iroha's Java SDK
[Java] Where did you try using java?
Try running React Navigation v5 demo app using Docker + Expo (For Mac)