Skip to content

Latest commit

 

History

History
103 lines (94 loc) · 2.09 KB

README.md

File metadata and controls

103 lines (94 loc) · 2.09 KB

Docker Basic

  • To check Docker vesrion
docker version
  • To check all the available images
docker images
  • Pull/Download the image from the Docker registry/Hub to local machine.
docker pull <image name>
//Eg: docker pull mysql
  • To run the images
    • Additional flags
      • -it - For interactive environment
      • -d - To run in detached mode
      • -p <Host port:container port> - To forward the port
        E.g.- docker run -d -p 8080:80 nginx
docker run <image_name>
// E.g - docker run hello-world
  • To check all the running images
docker ps
  • To see all the container list
docker container ls
  • Attached bash cell to running container
docker exec -it <container_id> bash
  • To check logs
docker ps -a
  • To delete all the stop container
docker container prune -f
  • Check log of container
docker logs <container-id/name>
  • To start the container
docker start <container-id/name>
  • To stop the container
docker stop <container-id/name>
  • To remove the container
docker rm <container-id/name>
  • To remove the image
docker rmi <image-name> -f
  • To share the container with others
docker commit -m "commit message" <container-id> <imagen-name:version>
// E.g - docker commit -m "added name.txt file" a17b78de1961 name_ubuntu:1.01
  • To get id of all the images
docker images -q
  • To delete all the images at once
docker rmi $(docker images -q)
  • Creating our own image and container
step 1 - create Docker file (and write comand)
step 2 - docker build -t <image-name:verison> <path of docker file>
step 3 - docker run <image-name>
  • Install Scout on Docker (Scan project vulnerability)
# First download the script 
step 1 - curl -fsSL https://raw.githubusercontent.com/docker/scout-cli/main/install.sh -o install-scout.sh
# Second run the script 
step 2 - sh install-scout.sh
# Now Scout is install you can check your Scout version
step 3 - docker scout verison