Docker

Installing Docker

Add Docker’s GPG key

sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

Setup the Docker Repo

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update

Install the Docker Engine

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Pull an Image from DockerHub

sudo docker pull debian

Create a Docker Image from a Running Container

docker commit [container ID] [new image name]

E.g.

docker commit busy_wiles nadimdg/xmrig:auto4

List All Running Containers

docker ps

List All Containers

docker ps -a

Delete a Container

docker rm <container-name>

List all Docker Images

docker images

Delete a Docker Image

docker rmi <image-name>

Login to a Running Docker Container

docker exec -it xmrig-dev /bin/sh

Run a Container

This starts the container and detaches the process from it.

docker run -di --name flast101 alpine:latest

Where:

-d: detach
-i: interactive

Stop a Container

docker stop <image-name>

Create a Container from a Dockerfile

Create a Dockerfile

First create a docker file. An example is shown below, let’s call it p2pooldev.Dockerfile.

FROM p2pool:built
WORKDIR /opt/p2pool
CMD ["/opt/p2pool/p2pool"]

Note that if the CMD requires arguments, then in the Dockerfile you must split the command and it’s arguements as shown below:

CMD ["/bin/ls", "-l", "-t", "-r"]

Create a Docker Image from a Dockerfile

docker build -f p2pooldev.Dockerfile -t sallykolodny/db4e:p2pooldev .

Where:

The odd name is to align with a Dockerhub account where the account name is sallykolodny, the repository is called db4e and the version of the image is p2pooldev. By using such a name you can easily upload the image to Dockerhub after authenticating. Create a container and start it up.


Push a Docker image to DockerHub

docker push nadimdg/xmrig:autostart

Links