Skip to content

Instantly share code, notes, and snippets.

@NISH1001
Last active December 10, 2019 04:55
Show Gist options
  • Save NISH1001/3082630b11efe76f852d5fee5cec0510 to your computer and use it in GitHub Desktop.
Save NISH1001/3082630b11efe76f852d5fee5cec0510 to your computer and use it in GitHub Desktop.
Docker barebone configurations

build docker image

docker build -t <imagename> .

example

docker build -t testapi

run image

docker run -p <host_port>:<original_port> <imagename>

example

docker run -p 8080:8000 testapi

This maps the original api (running in the container) at port 8000 to 8080 in the local system.

generic form

docker run -d --name ra -p 8080:8000 testapi

list docker processes

docker ps -a

list docker images

docker images

remove docker process using container id

docker rm <container_id>

remove all the stopped processes

docker container prune

kill the container process running in the background

docker kill <container_id>

Enter As Root

First get container process id.

docker inspect --format {{.State.Pid}} <container_name_or_ID>

Now, enter as root

nsenter --target <PID> --mount --uts --ipc --net --pid

Enter as super user with su command.
Install anything now.

Remove All Unused Images

docker system prune -a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment