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