Git Product home page Git Product logo

docker-tips's Introduction

docker-tips

My ๐Ÿณ Docker CLI Tips and Tricks

Installation

Linux

$ curl -sSL https://get.docker.com/ | sh
$ docker version

macOS

if you have Homebrew-Cask, just type:

$ brew cask install docker
$ docker version

Containers

Starting and Stopping

  • docker start starts a container so it is running.
  • docker stop stops a running container.
  • docker restart stops and starts a container.
  • docker pause pauses a running container, "freezing" it in place.
  • docker unpause will unpause a running container.
  • docker wait blocks until running container stops.
  • docker kill sends a SIGKILL to a running container.
  • docker attach will connect to a running container.

CPU Constraints

The setting is a bit strange -- 1024 means 100% of the CPU, so if you want the container to take 50% of all CPU cores, you should specify 512

docker run -it -c 512 agileek/cpuset-test

Volumes

Lifecycle

$ docker volume create
$ docker volume rm

Info

$ docker volume ls
$ docker volume inspect

Exposing ports

Mapping the container port to the host port (only using localhost interface) using -p:

$ docker run -p 127.0.0.1:$HOSTPORT:$CONTAINERPORT --name CONTAINER -t someimage

Listens on the specified network ports at runtime by using EXPOSE:

$ EXPOSE <CONTAINERPORT>

To expose the container's port on your localhost's port:

$ iptables -t nat -A DOCKER -p tcp --dport <LOCALHOSTPORT> -j DNAT --to-destination <CONTAINERIP>:<PORT>

If you forget what you mapped the port to on the host container, use docker port to show it:

$ docker port CONTAINER $CONTAINERPORT

Tips

Prune

The new Data Management Commands have landed as of Docker 1.13:

$ docker system prune
$ docker volume prune
$ docker network prune
$ docker container prune
$ docker image prune

References

docker-tips's People

Contributors

sungjk avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.