Docker

Useful docker commands

  • docker build -t [image name] .
  • docker images -a
  • docker ps -a
  • docker run [image name]
  • docker run -d –name [container name] [image name]
  • docker run -v [/host/directory]:[/container/directory] [image name]
  • docker start [container name]
  • docker exec -it [container name] /bin/bash
  • docker rmi [image name]
  • docker rm [container name]
  • docker inspect [container_name]
    to get ip address
  • docker search [image name]
    to search image on docker hub and list whether it is official or not

Sample Docker File

FROM php:7.0-apache  
COPY [source directory] /var/www/html
EXPOSE 80

NOTE:

  • Keep the name of file Dockerfile only
  • Keep the source project directory in the same level where Dockerfile file is present