README.md 1.1 KB

From https://www.codeschool.com/screencasts/build-a-node-app-with-postgres-and-docker

  • Run nginx

    • in foreground
      • docker run -p 81:80 --name web nginx
    • in foreground and removing it when stopped
      • docker run -p 81:80 --name web --rm nginx
    • in background
      • docker run -p 81:80 --name web -d nginx
    • foreground, mounting the nginx/html directory:

      docker run --rm \
      -p 81:80  \
      --name web \
      --mount type=bind,source=$PWD/nginx/html,target=/usr/share/nginx/html \
      nginx
      
  • Enter the container:

    docker exec -it web /bin/bash
    
  • Build a local image from the Dockerfile

    docker build -t osinet/nginx:latest .
    
  • Run the newly built image:

    docker run --rm \
    -p 81:80 \
    --name web \
    --mount type=bind,source=$PWD/nginx/html,target=/usr/share/nginx/html \ 
    osinet/nginx
    
  • List images

    • All except intermediates: docker images
    • All including intermediates: docker images -a
    • Images with this name: docker images osinet/nginx