_________________________________________________________________
a0
_________________________________________________________________
Docker uitvoeren op Linux.
_________________________________________________________________
--1. RedHat Linux
https://docs.docker.com/engine/install/rhel/
Anderen: CentOS, Debian, Fedora, Ubuntu
Installeren | Docker Docs
_________________________________________________________________
--2. Docker installeren op RedHat Linux
dnf remove docker
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine \
podman \
runc
sudo dnf -y install dnf-plugins-core
sudo dnf config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo
sudo dnf install docker-ce docker-ce-cli containerd.io docker-buildx-plugin \
docker-compose-plugin
docker login
sudo systemctl enable --now docker
sudo systemctl start docker
sudo systemctl stop docker
sudo systemctl status docker
sudo systemctl disable docker
sudo docker run hello-world
--docker verwijderen
sudo dnf remove docker-ce docker-ce-cli containerd.io docker-buildx-plugin \
docker-compose-plugin docker-ce-rootless-extras
sudo rm -rf /var/lib/docker
sudo rm -rf /var/lib/containerd
_________________________________________________________________
sudo systemctl enable --now docker
Foutmelding van daemon: toomanyrequests:
Je hebt je niet-geauthenticeerde pull-limiet bereikt.
https://www.docker.com/increase-rate-limit
--Oplossing:
docker login
Je moet een docker account aanmaken op https://docker.coma0> 'Aanmelden' > Geen account? 'Registreren'.
_________________________________________________________________
--3. Stap-voor-stap: Docker toegang geven aan een niet-root gebruiker
1. Zorg dat Docker geïnstalleerd en actief is
sudo systemctl status docker
2. Maak de docker groep aan (als die nog niet bestaat)
sudo groupadd docker
grep docker /etc/group
getent group | grep docker
getent group docker
cat /etc/group | grep docker
Deze stap is meestal niet nodig als Docker al geïnstalleerd is.
3. Voeg je gebruiker toe aan de docker groep
sudo usermod -aG docker jouw_gebruikersnaam
'jouw_gebruikersnaam' vervangen door de daadwerkelijke gebruikersnaam.
sudo usermod -aG docker dockerauto
# useradd -g docker dockerauto
# id -a dockerauto
passwd dockerauto
docker.4Automation@Harness&Test
4. Log out and log back in
This step is important to apply the new group membership. You can also use:
newgrp docker
to apply the group change without logging out.
5. Test Docker access
docker run hello-world
_________________________________________________________________
--4. Docker Linux Directory
https://docs.docker.com/engine/daemon/
Yes, in Docker, it is possible to choose the Linux directory where container data is stored, but it requires configuring the Docker storage directory.
By default, Docker stores all its data (images, containers, volumes, etc.) in:
/var/lib/docker
To change this directory:
Modify the Docker Daemon Configuration
Create or edit the Docker daemon config file:
sudo nano /etc/docker/daemon.json
Add or modify the data-root setting:
{"data-root": "/your/custom/docker-directory"}
Stop Docker:
sudo systemctl stop docker
Move existing data (optional but recommended if you want to preserve current containers/images):
sudo rsync -aP /var/lib/docker/ /your/custom/docker-directory
Start Docker:
sudo systemctl start docker
Verify:
docker info | grep "Docker Root Dir"
Example:
root@PS026300 dockerhome# cat /etc/docker/daemon.json
{
"data-root": "/dockerhome/dockerdata"
}
root@PS026300 dockerhome#
systemctl stop docker
mv /var/lib/docker/* /dockerhome/dockerdata/.
ls -la /var/lib/docker
ls -la /dockerhome/dockerdata
systemctl start docker
systemctl status docker
docker info | grep "Docker Root Dir"
_________________________________________________________________
--5. RedHat Linux - How to Create a Linear Volume
# fdisk -l /dev/sdc
Disk /dev/sdc: 214.7 GB, 214748364800 bytes, 419430400 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
# fdisk /dev/sdc
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0xe890f319.
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-419430399, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-419430399, default 419430399):
Using default value 419430399
Partition 1 of type Linux and of size 200 GiB is set
Command (m for help): p
Disk /dev/sdc: 214.7 GB, 214748364800 bytes, 419430400 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xe890f319
Device Boot Start End Blocks Id System
/dev/sdc1 2048 419430399 209714176 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
# fdisk -l /dev/sdc
Disk /dev/sdc: 214.7 GB, 214748364800 bytes, 419430400 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xe890f319
Device Boot Start End Blocks Id System
/dev/sdc1 2048 419430399 209714176 83 Linux
#
--Volume group
# vgcreate vgdockerhome /dev/sdc1
# vgscan
# vgdisplay vgdockerhome
--Logical Volume
# lvcreate -l 51199 vgdockerhome -n lvdockerhome
# lvdisplay -v /dev/vgdockerhome/lvdockerhome
--Format the volume
--# mkfs.ext3 /dev/vgdockerhome/lvdockerhome
--# mkfs.ext4 /dev/vgdockerhome/lvdockerhome --rhel_7,8,9
# mkfs.xfs /dev/vgdockerhome/lvdockerhome --rhel_7,8,9
--Mount
# mkdir /pghome
--# mount -t ext3 -o noatime /dev/vgdockerhome/lvdockerhome /dockerhome
--# mount -t ext4 -o noatime /dev/vgdockerhome/lvdockerhome /dockerhome --rhel_7,8,9
# mount -t xfs -o noatime /dev/vgdockerhome/lvdockerhome /dockerhome --rhel_7,8,9
--Persist the mount
vi /etc/fstab
#mount logical volume
#/dev/vgdockerhome/lvdockerhome /dockerhome ext3 defaults,noatime 1 1
#/dev/vgdockerhome/lvdockerhome /dockerhome ext4 defaults,noatime 1 1 <== --rhel_7,8,9
/dev/vgdockerhome/lvdockerhome /dockerhome xfs defaults,noatime 1 1 <== --rhel_8,9
:wq!
--How to remove volumes
--remove logical volume
# lvremove /dev/vgdockerhome/lvdockerhome
--remove volume group
# vgremove vgdockerhome
--More info at:
Configuring and managing logical volumes | Red Hat Enterprise Linux | 9 | Red Hat Documentation
_________________________________________________________________
--6. Docker CLI on Windows
Install Docker CLI Only (Without Docker Engine) If you only need the CLI to connect to a remote Docker host: Step-by-Step: Download Docker CLI binaries Visit:https://download.docker.com/win/static/stable/x86_64/ Extract the ZIP file to a folder (e.g., C:\docker-cli). Add the folder to your system PATH: Open System Properties > Environment VariablesUnder System variables, find Path, click Edit, and add the path to your Docker CLI folder. Open a new terminal and test:
docker --version
This method is useful if you're using Docker with remote hosts (via SSH or TLS) and don’t need Docker Engine running locally.
_________________________________________________________________
--7. To use the Docker CLI on Windows to control a Docker Engine running on a remote Linux host over SSH, follow these steps: 1. PrerequisitesDocker installed on Windows (Docker Desktop or Docker CLI)Docker Engine running on the Linux hostSSH access from Windows to the Linux hostYour SSH key added to the Linux host (or password access enabled) 2. Enable SSH Access to Docker on LinuxEnsure the Linux host has Docker running and SSH access enabled. You can test SSH access from Windows (PowerShell or Git Bash):
ssh user@linux-host-ip
3. Use Docker CLI with SSH ContextOption A: One-time command
docker -H ssh://user@linux-host-ip info
Option B: Create a Docker contextThis is more convenient for repeated use:
docker context create my-linux-docker \
--docker "host=ssh://user@linux-host-ip"
Then switch to that context:
docker context use my-linux-docker
Now, any docker command you run will be executed on the remote Linux host. 4. Verify
docker info
5. Optional: Use SSH Key
docker -H "ssh://user@linux-host-ip" --ssh-option IdentityFile=~/.ssh/id_rsa info
To set up a custom SSH key for Docker CLI to connect to a remote Docker Engine over SSH, follow these steps: 1. Generate a Custom SSH Key (if you don’t have one yet)On your Windows machine (using PowerShell or Git Bash):
ssh-keygen -t rsa -b 4096 -f ~/.ssh/my_custom_key
This creates:~/.ssh/my_custom_key (private key)~/.ssh/my_custom_key.pub (public key) 2. Copy the Public Key to the Linux Host
ssh-copy-id -i ~/.ssh/my_custom_key.pub user@linux-host-ip
If ssh-copy-id is not available, you can manually append the key:
cat ~/.ssh/my_custom_key.pub | ssh user@linux-host-ip "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"
3. Test SSH with the Custom Key
ssh -i ~/.ssh/my_custom_key user@linux-host-ip
If it logs in without a password, you're good to go. Optional: Use SSH Agent for Passphrase-Protected KeysIf you used a passphrase, you can use ssh-agent to avoid entering it every time: Install SSH Agent via PowerShell1. Open PowerShell as Administrator2. Check if OpenSSH Client is Installed:
Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH.Client*'
3. If it shows State : NotPresent, install it:
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
4. Enable and Start the SSH Agent Service:
Set-Service -Name ssh-agent -StartupType Automatic
Start-Service ssh-agent
--open new powershell windows not as administrator
ssh-add $env:USERPROFILE\.ssh\id_rsa
ssh-add -l
--do this in powershell in the windows machine. 4. Use Docker CLI with the Custom SSH KeyOptie A: Eenmalige opdracht
docker --context default -H "ssh://user@linux-host-ip" \
--ssh-option IdentityFile=~/.ssh/my_custom_key info
Optie B: Maak een Docker-context aan met de aangepaste sleutel
docker context create my-linux-docker \
--docker "host=ssh://user@linux-host-ip" \
--description "Remote Docker met aangepaste SSH-sleutel"
Stel vervolgens de omgevingsvariabele in om de sleutel te gebruiken:
export DOCKER_SSH_IDENTITYFILE=~/.ssh/my_custom_key
docker context use my-linux-docker
_________________________________________________________________
--8. Stapsgewijs Voorbeeld:
docker linux engine server - PS026300
docker linux gebruikersnaam: dockerauto
!!! gebruiker dockerauto is lid van de docker-groep om het docker-commando te kunnen uitvoeren !!!
docker linux gebruikerswachtwoord: docker.auto
Windows Machine:
powershell: ssh dockerauto@PS02630
docker -H ssh://dockerauto@PS026300 info
docker context ls
docker context rm linux-docker-PS026300
docker context create linux-docker-PS026300 --docker "host=ssh://dockerauto@PS026300"
docker context use linux-docker-PS026300
docker context show
docker ps -a
docker context list
Windows Machine:
powershell:
cd c:\temp\ssh_key
ssh-keygen -t rsa -b 4096 -f c:\temp\ssh_key\PS026065_ssh_key
wachtwoordzin: docker.auto
--ssh-copy-id -i c:\temp\ssh_key\PS026065_ssh_key.pub dockerauto@PS026300
--Als ssh-copy-id niet beschikbaar is, kunt u de sleutel handmatig toevoegen:
cat c:\temp\ssh_key\PS026065_ssh_key.pub | ssh ssh://dockerauto@PS026300 "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"
Linux Machine:
su - dockerauto
pwd
ls -la $HOME/.ssh
cat $HOME/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
chmod 700 ~/.ssh
Windows Machine:
powershell:
--Test SSH met de aangepaste sleutel
ssh -i c:\temp\ssh_key\PS026065_ssh_key dockerauto@PS026300
--open nieuwe powershell-vensters als administrator
Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH.Client*'
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
Set-Service -Name ssh-agent -StartupType Automatic
Start-Service ssh-agent
--open nieuwe powershell-vensters zonder administratorrechten
mkdir C:\Users\marc3932\.ssh\id_rsa
New-Item -Path "C:\Users\marc3932\.ssh\id_rsa" -ItemType Directory
Copy-Item -Path "c:\temp\ssh_key\PS026065_ssh_key\*" -Destination "C:\Users\marc3932\.ssh\id_rsa" -Recurse
--(het is mogelijk dat het niet gekopieerd is, controleer dit en kopieer handmatig indien nodig)
ssh-add $env:USERPROFILE\.ssh\id_rsa\PS026065_ssh_key
ssh-add -l
--verwijder de sleutel
ssh-add -d $env:USERPROFILE\.ssh\id_rsa\PS026065_ssh_key
--verwijder alle sleutels
ssh-add -D
--Test SSH met de aangepaste sleutel
ssh -i c:\temp\ssh_key\PS026065_ssh_key dockerauto@PS026300
ssh dockerauto@PS026300
Windows Machine:powershell:
--Optie A: Eenmalige opdracht
--docker --context default -H "ssh://dockerauto@PS026300" --ssh-option IdentityFile=c:\temp\ssh_key\PS026065_ssh_key
--docker -H "ssh://dockerauto@PS026300" --ssh-option IdentityFile=c:\temp\ssh_key\PS026065_ssh_key
docker -H "ssh://dockerauto@PS026300" info
--Optie B: Maak een Docker-context aan met de aangepaste sleutel
docker context rm linux-docker-PS026300
docker context create linux-docker-PS026300 --docker "host=ssh://dockerauto@PS026300" --description "Linux Docker Agent PS026300 met aangepaste SSH-sleutel"
--Stel vervolgens de omgevingsvariabele in om de sleutel te gebruiken:
docker context use linux-docker-PS026300
_________________________________________________________________