https://stackoverflow.com/questions/33066528/should-i-use-docker-compose-up-or-run#:~:text=Basically%2C%20use%20docker%2Dcompose%20run,to%20spawn%20a%20new%20service.
**********docker-compose run will create a temporary container for the service and run the command on the service, but no container for other services that the current service depends on, and it will remove the container afterwards********************no ports will be created for the service
******************************** ********************
docker-compose run - creates a one time running service with container and execute command against the service. then the service is destroyed.
docker-compose up creates a container for service listed in yml file,(one container for 1 service)
docker-compose up --help for paramters. -t for running in detrached mode.
docker-compose up -d (detach mode running in background https://stackoverflow.com/questions/59838692/mysql-root-password-is-set-but-getting-access-denied-for-user-rootlocalhost)
docker-compose down -v (stops and removes containers and removes volume with v flag)
docker-compose ps(for list of containers and status)
docker-compose up --force-recreate (force recrate the container )
docker-compose build --no-cache(redownload)#Note docker-compose build does not work if no image in requiremnts.txt specified or image is in yml file
docker compose up detailed parameters docker-compose up --help (https://stackoverflow.com/questions/36884991/how-to-rebuild-docker-container-in-docker-compose-yml)
//login to container
https://geshan.com.np/blog/2022/02/mysql-docker-compose/
# access a caontainer with /bin/bash cmds
1) docker exec -it <container_name> /bin/bash
2) docker-compose exec <service_name> /bin/bash
// exit container
exit
# Note for alpine version
/bin/bash does not exist, use docker-compose exec <service_name> sh
Docker compose down terminates and removes any running container
docker-compose down --help
docker-compose down -v (removes volume in the container as well)
No comments:
Post a Comment