Docker Documentation - mohanrobotics/Documentation GitHub Wiki

Docker Commands

Building Docker image

docker build -t <IMG_NAME>:<TAG_NAME> . --no-cache=true

Run Docker container

docker run --gpus all -it --rm -v $PWD/<DIR>:/home/<DIR> <IMG_NAME>:<TAG_NAME> bash

Detach the container that run in -it mode

Ctrl + P , Ctrl + Q

Detach the container that run in -it mode

docker attach CONTAINER_NAME

Pull a docker image

docker pull <IMAGE_NAME>

Docker Execute on a running container

docker exec -it <CONTAINER_NAME> bash

List the docker images

docker images

List the Running containers

docker container ls

Kill the Running containers

docker kill <CONATAINER_ID>

Restart the system docker

sudo systemctl restart docker

Specifying the network as host

Add --network --host while running the container

Enable forwarding from Docker containers to the outside world

In the host machine do,
sudo sysctl net.ipv4.conf.all.forwarding=1

sudo iptables -P FORWARD ACCEPT

⚠️ **GitHub.com Fallback** ⚠️