0% found this document useful (0 votes)
65 views1 page

Docker CheatSheet

This document provides instructions for installing Docker and performing common operations like running containers, managing networks, debugging containers, and more. It explains how to install Docker, add a user to the Docker group, run containers from images, manage container lifecycles, connect containers to networks, view logs and inspect configuration, and debug running containers.

Uploaded by

Qing Shi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views1 page

Docker CheatSheet

This document provides instructions for installing Docker and performing common operations like running containers, managing networks, debugging containers, and more. It explains how to install Docker, add a user to the Docker group, run containers from images, manage container lifecycles, connect containers to networks, view logs and inspect configuration, and debug running containers.

Uploaded by

Qing Shi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

DOCKER INSTALLATION $ docker container stop $(docker {{.

Driver}}"
Install packages to allow apt to use a container ls -a -q) To inspect any Network (Returns
repository over https To list all running and stopped Containers information about one or more networks.)
$ sudo apt install apt-transport-https ca- $ docker container ls -a $ docker network inspect
certificates curl software-properties- To mount a host volume in a Container To create new Network on Host Machine
common $ docker container run --publish 80:8080 $ docker network create -d bridge
Add docker's official GPG key -v /opt/myfolder:/hostfolder tomcat:jre8 <Network Name>
curl –fsSL To run a command in a Container in To connect Network with Container
https://download.docker.com/linux/ubu interactive mode (SSH a running $ docker network connect <Network
ntu/gpg | sudo apt-key add - container) Name> <Container Name>
To setup the stable repository $ docker container exec -it <container id> To disconnect Network with Container
$ sudo add-apt-repository "deb bash $ docker network disconnect <Network
[arch=amd64] To commit the changes in the Container Name> <Container Name>
https://download.docker.com/linux/ubu $ docker commit -a "<author>" --m To remove Network
ntu bionic stable" "message" <container name> <repository $ docker rm <Network Name>
$ sudo apt update name:tag>
Install Docker Community Edition (CE) To remove Containers
$ apt-cache policy docker-ce $ docker container rm <space separated
$ sudo apt install docker.ce container ids>
To verify Docker installation status To bulk remove docker Containers
$ sudo systemctl status docker $ docker container rm $(docker container
$ sudo ps -ef | grep [d]ocker ls -a -q)
To add username to the Docker group, to To bulk remove all exited containers
avoid using sudo to execute the docker $ docker container rm $(docker ps -a -q -f
command. status=exited)
$ sudo usermod -aG docker ubuntu DEBUGGING THE DOCKER CONTAINERS
To view Docker version and information To verify Docker installation status
$ docker version $ sudo systemctl status docker
$ docker info $ sudo ps -ef | grep [d]ocker
WORKING WITH DOCKER CONTAINERS $ docker version
To search the docker hub for images $ docker info
$ docker search searchWord To see logs of a specific Container
To run Tomcat Image in docker $ docker container logs
$ docker container run --publish 80:8080 <container_name>/<container_id>
tomcat:jre8 To see process running inside the
What does the above command do? Containers
1. Dowloaded the Images form Docker Hub
$ docker container top <container_id>
2. Started new Container
3. Exposed port 80 on Host Machine To list the details of Container config
4. Routes traffic to the container port 80 $ docker container inspect<container_id>
5. Starts container by using CMD in docker file To list the performance stats of all
To run MySQL Image in docker Containers
$ docker container run --publish $ docker container stats
3306:3306 --env NETWORKING IN CONTAINERS
MYSQL_RANDOM_ROOT_PASSWORD=ye To start container to allow traffic from
s mysql Port on Host machine
To stop Container fore-ground process $ docker container run --p
ctrl+c <host_port>:<docker_port> -d <image
To run container in Back-Ground or name>
detach mode To find the traffic and protocol on
$ docker container run --publish 80:8080 Container
--detach tomcat:jre8 $ docker container port <container_id>
To name a docker Container To find Docker Container IP
$ docker container run --publish 80:8080 $ docker container inspect --f
--detach --name <name> tomcat:jre8 '{{.NetworkSettings.IPAddress}}'
To list running Container <container_id>
$ docker container ls To show all networks
To stop docker Container $ docker network ls
$ docker container stop <container_id> To filter all bridge network
To start docker Container $ docker network ls -f driver=bridge
$ docker container start <container_id> To find all Network IDs and Drivers
To bulk stop docker Containers $ docker network ls --format "{{.ID}}:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy