Sunday 16 February 2020

Docker commands

docker stop -p 8080:8080 -d --env-file docker.env pcre-id:latest

docker stop 12d000d946a0

docker run --name :latest
docker tag /:tag
docker push /
docker commit
docker history
docker inspect : Return low-level information on Docker objects
docker logs
docker diff   : Inspect changes to files or directories on a container’s filesystem
docker rm

removing dangling images and containers
docker rm $(docker ps -a -f status=exited -q) : to remove the containers which are unused

docker login --u yourhubusername

docker tag yourhubusername/verse_gapminder:firsttry

Lifecycle

Starting and Stopping

Info

  • docker ps shows running containers.
  • docker logs gets logs from container. (You can use a custom log driver, but logs is only available for json-file and journald in 1.10).
  • docker inspect looks at all the info on a container (including IP address).
  • docker events gets events from container.
  • docker port shows public facing port of container.
  • docker top shows running processes in container.
  • docker stats shows containers' resource usage statistics.
  • docker diff shows changed files in the container's FS.
docker ps -a shows running and stopped containers.
docker stats --all shows a running list of containers.

Import / Export

  • docker cp copies files or folders between a container and the local filesystem.
    docker cp 7e5c370eef0c:/usr/bin/AffyAnalysis/R_Workspaces/affy /Users/narendra.raghuwanshi/Documents/affynew

  • docker run -it --name affyfine f7c545621aa1 /usr/bin/bash
    cd /Users/narendra.raghuwanshi/Documents/affynew
    docker cp ./affy affyfine:/
    docker start affyfine
    docker exec -it affyfine /usr/bin/bash

  • docker cp :/file/path/within/container /host/path/target)
          docker cp /Users/narendra.raghuwanshi/Documents/affynew/ 661eb7a0df74:/temp
cp /Users/narendra.raghuwanshi/Documents/TFScode/Rcode/NewR/affy_headmaster.R 2591e5d2023c:/.   (for directory)
    
    FROM container to container
        
First of all, copy file to some temporary directory on the host Next, transfer it from the temp directory to the other container:
  • docker export turns container filesystem into tarball archive stream to STDOUT.

Lifecycle

  • docker images shows all images.
  • docker import creates an image from a tarball.
  • docker build creates image from Dockerfile.
  • docker commit creates image from a container, pausing it temporarily if it is running.(alway give alias name to ur commit )
  • docker rmi removes an image.
  • docker load loads an image from a tar archive as STDIN, including images and tags (as of 0.7).
  • docker save saves an image to a tar archive stream to STDOUT with all parent layers, tags & versions (as of 0.7).

Info

where everything stored in our Machine.