Last active
January 15, 2021 16:03
-
-
Save dylansalim3/06db28d14713c1488306ed3ca81b86dc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Build docker file with a given tag | |
docker build -t {tag-name} {docker-location} | |
example -> docker build -t node-app-test . | |
//run docker in interactive mode | |
docker run -it -p {exposed-machine-port}:{application-port} {tag-name} | |
example -> docker build -t 9000:3000 node-app-text | |
// run container in the background/detach mode | |
docker run -d -p {exposed-machine-port}:{application-port} {tag-name} | |
// example of running docker container with listening to the current directory | |
docker run -d -p 9010:5000 --name qr_menu_backend -v $(pwd):/app qr_menu_backend | |
// list all container | |
docker ps -a | |
docker stop {container-id} | |
// start existing docker container in interactive mode | |
docker start -i {container-id} | |
docker restart {container-id} | |
//remove docker container | |
docker rm {docker-id} | |
//list all existing docker images | |
docker images | |
// remove docker image | |
docker image rm {image_id} | |
//show docker list | |
docker ps | |
// run docker run in volume mode, for the example below, any changes on the current directory will be affected the files inside the app folder | |
docker run -it/-d -p {} -v $(pwd):/app {tag-name} | |
//cheat sheet link | |
https://www.docker.com/sites/default/files/d8/2019-09/docker-cheat-sheet.pdf | |
// In docker, if we want to use the host machine ip address in our application, in our docker-compose file -> | |
environment: | |
DB_ENV: http://${DOCKER_GATEWAY_HOST:-host.docker.internal}:3000 | |
//If the machine is linux based, we need to add the following line to ~/.bashrc (took the 1st ip) | |
export DOCKER_GATEWAY_HOST="`hostname -I` |awk '{print $1}' `" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment