Skip to content

Docker

Export a Docker Image

docker save image:tag > image.tar

You can also compress the image:

gzip image.tar

Prepare a Docker Container as a Remote Server

Reference

Take an Ubuntu-based image as an example.

Start a container with port forwarding:

docker run -d -p 2222:22 sshd-image

Inside the container:

apt update && apt install openssh-server

Allow SSH login as root:

sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config

Then set a password:

passwd

Start the OpenSSH server:

service ssh start

Push Image to GHCR

echo ghp_xxx | docker login ghcr.io -u <username> --password-stdin
docker build . -t ghcr.io/<username>/<repo>:latest
docker push ghcr.io/<username>/<repo>:latest