Skip to content

Instantly share code, notes, and snippets.

@kalaspuffar
Last active June 12, 2022 08:18
Show Gist options
  • Save kalaspuffar/334f81d11da28df6fa8dbf24910935b0 to your computer and use it in GitHub Desktop.
Save kalaspuffar/334f81d11da28df6fa8dbf24910935b0 to your computer and use it in GitHub Desktop.

Working with docker and registry

First of we install the docker client, server and registry on our debian machine.

apt install docker docker.io docker-registry

The registry could be installed as a service in our docker cloud as well.

docker run -d -p 5000:5000 --restart=always --name registry registry:2

Looking at the /etc/docker/registry/config.yml we can add all the configuration we need as well as SSL keys or connections to letencrypt so we can have a free and good connection to our repository. Securing a local or remote repository is key.

Next up we will create our own debian image by bootstrapping the buster distribution.

apt install debootstrap
debootstrap buster buster

Next up we will take that directory, package it up and import that into a new docker image called buster. We also will run it to ensure it works well and have the right version.

tar -C buster -c . | docker import - buster
docker run buster -t container-buster cat /etc/os-release

Next up we tag the newly created version for our repository and then push it up to the repository.

docker tag buster localhost:5000/my-debian
docker push localhost:5000/my-debian

We can now visit the server at http://[ip]:5000/my-debian/tags/list to see that we have a newly uploaded and tagged version in our repository.

Next up we will prune our local system and remove any traces of installed images or containers. This should not be done on a production environment as you may remove running important business logic. But for our example this is fine.

docker system prune -a

Now I will create a simple docker image that will use our debian version and install PHP as a dependency.

from localhost:5000/my-debian

run apt update
run apt install -y php

Building the docker image and then running it to ensure that we have the correct version of PHP is done by the commands below.

docker build -t php-install .
docker run php-install php -v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment