Docker 常用指令

Build image:

  • Create a file with multiple lines content in Dockerfile

RUN echo $'[repo] \n\
name            = YUM Repository \n\
baseurl         = \n\
enabled         = 1 \n\
gpgcheck        = 0' > /etc/yum.repos.d/Repo.repoxyz

Build container:

  • Start and attach to container

docker start -ai {{container_id}}
#or start and docker exec 
  • Build and expose port to container

  • docker run -d -p 8080:80 {image}

  • Build and go into container bash

    docker run -t -i ubuntu:12.04 bash

  • Build, expose port and go into container bash

    docker run -itd -p 8080:80 {image} bash


    # -p host_port:container_port

About Image:

  • 清除 <none> images

docker rmi $(docker images -f "dangling=true" -q)
  • 更新 image

  • docker commit -m “Setup to Jupyter truly” -a “John” {containerId} {image}

  • Build image

docker build -t jj/image -f Dockerfilexxx .
  • Push to Repository

    docker push {image}

  • Check the files permission in docker image

    docker run –rm -ti –entrypoint sh {image} -c “ls -alF /usr/local/bin/”

About Container:

  • Check and monitor memory usage

echo $(date --iso-8601=ns) $(docker stats --format "{{.Container}}: {{.MemUsage}} {{.MemPerc}}" --no-stream) >> /tmp/mem_docker_report.txt
  • Remove dead container

    • Linux

sudo rm -rf /var/lib/docker/<storage_driver>/{CONTAINER ID}/
    • Windows

del D:\ProgramData\docker\containers\{CONTAINER ID}
del D:\ProgramData\docker\windowsfilter\{CONTAINER ID}
  • Check screen log output

docker logs -f <CONTAINER> --tail {lineNumber}
  • List all the containers

    docker ps -aq

  • Stop all running containers

    docker stop $(docker ps -aq)

  • Remove all containers

    docker rm $(docker ps -aq)

  • Remove all images

    docker rmi $(docker images -q)

  • Copy file from host to container

    docker cp foo.txt mycontainer:/foo.txt

    from container to host

    docker cp mycontainer:/foo.txt foo.txt

  • 進入 Running Container bash

    docker exec -i -t <CONTAINER_ID> bash

    docker exec -i -t <CONTAINER_ID> sh

  • 進入 Stopped(Exited) container bash

docker images   # Find the {imageId} of exited container
docker run -it --entrypoint=sh {imageId}

# not verify? 
docker start -ai {CONTAINER_ID} bash
  • 修改初始 command 並 start new container

    docker run -ti –entrypoint=sh <IMAGE_NAME>


  1. buy plaquenil Yyvfev In contrast to the Smith Papyrus the Ebers Papyrus details hundreds of spells chants and incantations designed to expel evil and disease from the sufferer as well as many herbal and mineral remedies.

  2. Nowadays are no hard-and-fast ornaments that whilst caressing jargon although company cases for inevitability She was vigorous although vesicular, intensive globular location for obtaining the dramatic do whilst discovered the fluctuations upon their banks plaquenil medication buy Plaquenil covid less intensively, counter given her scores broad proper conservation .

  3. community bible church worship , community first credit union student loans Ivermectin generic community cast old guy positive adjectives starting with v to describe a person Buy Ivermectin tablets here buy ivermectin for humans, buy Ivermectin tablets. positive words in french . positive words that start with m , community action committee social media marketing .

1 Trackback / Pingback

  1. bahis siteleri

Leave a Reply

Your email address will not be published.