Many times you may have to start developing or setting up new software on a docker environment. So i decided to write this is a quick guide to install a fresh docker setup on a Debian 12 OS. This is very important because nowadays the most of opensource software has a docker build and install, so it is so useful to be able to install it on a fresh system. In this article also a basic security strategy is put in place, just to have a good starting point for your development platform.
Basic system setup
Create underprivileged user, then add to sudo group. In this case i named “dev” this new user. You can name is as you prefer.
adduser dev
usermod -aG sudo dev
Now on exec all the process with dev user, so switch the working user to this one.
Let’s go on in installing some useful package
sudo apt-get update
sudo apt-get install git vim-nox wget ufw
Docker setup
Some parts of this setup process are described into the official docker documentations. Let’s start dis-installing packages Many t may give conflicts
for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do sudo apt-get remove $pkg; done
Set up the repository
sudo apt-get update
# Add Docker's official GPG key:
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
Add the docker repository to Apt sources:
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
now install latest version
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Add user dev to docker group
sudo usermod -a -G docker dev
Check if all is ok by running
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
You can now run your own software on docker, either building images or downloading them from the dockerhub repository.
Vim useful setting
For people using the superpowerful Vim (like me), you should enable copy/paste using the mouse. for doing that, just access the file
sudo /usr/share/vim/vim90/defaults.vim
and change the parameter mouse=a to mouse=r at line 83, then save and exit the file. Then your Vim will be ready to use with copy/paste functions using the mouse.
Some basic security setup
sudo ufw default deny incoming
sudo ufw allow 22/tcp comment 'permit SSH incoming traffic'
sudo ufw enable
now check if all is ok
sudo ufw status
You may need to enable also different ports in case of need. the procedure is the same.
In order to make a more secure connection, copy your ssh pubkey, adding it at bottom of the file ~/.ssh/authorized_keys on the server. Then
chmod 400 ~/.ssh/authorized_keys
Now you should test the SSH connection to the server using the key and then allow only a key SSH connection to the server (disallowing password connections). In order to do that, make some parameters change into the file /etc/ssh/sshd_config and set
PermitRootLogin no
PasswordAuthentication no
then restart the service
sudo /etc/init.d/ssh restart
The system is now ready (for basic purposes). In most of cases you now have a ready to go safe, docker setup, where you can develop your software, test, or run existing packages and images. If you are a professional, you may have to make additional install and settings you prefer. Enjoy
TOP