How to create docker-compose

How to write docker-compose

docker-compose.yml


version: '3'

services: 
    web:
        ##Specify the dockerimage file or specify your own Dockerfile.
        ##Image if the Dockerfile exists in the same directory: {imageName}
        build: {imageFileName}
        ports: 
            - '3000:3000'
        volumes:
            - '.:/product-file'
        tty: true
        stdin_open: true

tty:true → -t stdin_open: true → -i By specifying both, it will be in the same state as -it. volumes Specify the directory to be shared with the container. Create / product-file in the container and reflect the files in the hierarchy below docker-compose.yml in the container as it is. Even if the file contents are changed, they are reflected in real time. Command to execute

docker-compose build
docker-compose up
docker-compose ps
docker-compose exec {docker-compose.Service name specified in yml (web this time)}
##When you want to delete all the containers once created, such as when you make a mistake in the volume directory
docker-compose down (stop and rm)

At this point, the specified file will be mounted in the target container. docker-compose exec {app name} If you check the contents with bash, the file exists.

Since the files are volume, they are synchronized, but once the server is started, html etc. will not be generated dynamically, so it is necessary to start it again.

By building a CICD environment, you can update it again when you push it to git.

Recommended Posts

How to create docker-compose
How to write docker-compose
How to create an application
How to create a method
[Rails] How to speed up docker-compose
[Java] How to create a folder
How to deploy
How to create a Maven repository for 2020
[Swift5] How to create a splash screen
[rails] How to create a partial template
How to monitor nginx with docker-compose with datadog
How to write and explain Dockerfile, docker-compose
How to create a database for H2 Database anywhere
How to develop OpenSPIFe
How to call AmazonSQSAsync
How to use Map
Summary of how to create JSF self-made tags
How to write Rails
How to use rbenv
[Rails] How to create a graph using lazy_high_charts
How to use letter_opener_web
How to use with_option
How to use fields_for
How to use map
How to use collection_select
How to create pagination for a "kaminari" array
How to adapt Bootstrap
How to use Twitter4J
How to use active_hash! !!
How to create multiple pull-down menus with ActiveHash
How to install Docker
How to use MapStruct
How to use hidden_field_tag
How to use TreeSet
How to create a theme in Liferay 7 / DXP
How to write dockerfile
How to uninstall Rails
How to install docker-machine
[How to use label]
How to use identity
How to use hashes
How to write Mockito
How to create search conditions involving multiple models
[1st] How to create a Spring-MVC framework project
How to easily create a pull-down in Rails
Rails6.0 ~ How to create an eco-friendly development environment
[Rails] How to create a Twitter share button
How to use JUnit 5
How to create hierarchical category data using ancestry
How to install MySQL
How to write migrationfile
How to build android-midi-lib
How to create member variables with JPA Model
How to use Dozer.mapper
How to use Gradle
Notes on how to create Burp Suite extensions
How to use org.immutables
How to use java.util.stream.Collector
How to use VisualVM
How to create an oleore certificate (SSL certificate, self-signed certificate)
How to use Map