Git Product home page Git Product logo

docker's Introduction

Docker cheatsheet

Docker and its interesting world!

Docker is a platform for virtualization that helps developers and software engineers to run their applications in a separate and isolated environment. With Docker, you can define the software infrastructure needed to run your application in a separate and standardized way and package it with your application into a portable and self-sufficient unit called a Container.

Docker

This technology provides features such as isolation, fast configuration, and easy mobility between development and production environments. By using Docker, you only need to define a Docker container for your application and its required runtime environment, package it into a portable bundle, and then run it on any Docker-compatible system.

The use of Docker not only reduces installation and configuration time but also allows you to run your applications on platforms that have different characteristics such as different operating systems, versions, and libraries.

Docker

Better accessibility

The following mirrors can be used in nano /etc/docker/daemon.json to resolve internet problems:

{
  "registry-mirrors": ["https://docker.iranrepo.ir", "https://docker.arvancloud.ir", "https://docker.iranserver.com"]
}

Then, you can run the following commands:

systemctl daemon-reload
systemctl restart docker

Here are some important and useful Docker commands:

Container

  • Creating a container from a specific image
docker container run my_image
  • Creating a container from a special image and binding Docker port 8000 to 1000
docker run -i -t -p 1000:8000 --rm my_image /bin/bash
 :warning: You can use `/bin/bash` to have a better experience!
  • Creating a container from a special image and binding Docker port 8000 to 1000 host and bind mounting the /HostPath folder of the host to /insidePath of the container
docker run -v /HostPath:/insidePath -p 1000:8000 my_image
  • Creating a container from a specific image and executing the my_command command in Docker
docker container run -it my_image my_command
  • Create a container from specific image and detach it (Run in the background)
docker run -d -p 1000:8000 --rm --name my_image my_image:latest
  • Show list of my active containers
docker ps
  • Show list of all my containers
docker ps -a
  • Start a specific container
docker start CONTAINER_ID
  • Stop a specific container
docker stop CONTAINER_ID
  • Remove a specific container
docker rm CONTAINER_ID
  • Display logs of a specific container
docker logs CONTAINER_ID
  • Kill a specific container
docker kill CONTAINER_ID
  • Create new snapshot from running container
docker commit CONTAINER_ID new_image_name
  • Change timezone of container
 sudo rm -rf /etc/localtime
 ln -s /usr/share/zoneinfo/Asia/Tehran /etc/localtime

 # you can check it now :)
 date

Image

  • Show list of my docker images
docker images ls
  • Get a simple Hello-world image
docker pull hello-world
  • Run Hello-world docker image
docker run hello-world
  • Build Docker image
docker image build . -t my_repo/my_image:my_tag
  • Build Docker image from DockerFile
docker build -t my_repo/my_image:my_tag -f Dockerfile .
  • Create a backup from docker image
docker save --output bk_khalooei.tar my_image:latest
  • Load a docker image
docker load --input bk_khalooei.tar
  • More information about Docker Image
docker inspect <imagename>

Volume

  • Show list of my Docker volumes
docker volome ls
  • Display the information of a volume
docker volume inspect VOLUME_NAME
  • Delete all unused volumes
docker volume prune

MORE

  • Docker version
docker version
  • Enable Docker service on Linux
sudo systemctl enable docker
sudo systemctl start docker

References

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.