Skip to content

Instantly share code, notes, and snippets.

@rwcitek
Last active December 13, 2025 21:49
Show Gist options
  • Select an option

  • Save rwcitek/24e0a108e4cc251a60119b581706368b to your computer and use it in GitHub Desktop.

Select an option

Save rwcitek/24e0a108e4cc251a60119b581706368b to your computer and use it in GitHub Desktop.
Docker compose two Slackware containers running ssh
## environment setup
mkdir -p slackware.ssh/{slackware142,slackware150}
cd slackware.ssh
## architect images and containers using docker compose
cat <<'eof' > docker-compose.yml
services:
slackware142:
build:
context: ./slackware142
dockerfile: Dockerfile
container_name: slackware142_container
hostname: slack142
networks:
- slack_net
privileged: true
slackware150:
build:
context: ./slackware150
dockerfile: Dockerfile
container_name: slackware150_container
hostname: slack150
networks:
- slack_net
privileged: true
networks:
slack_net:
driver: bridge
eof
## Architect slackware 14.2 image using docker file
cat <<'eof' > slackware142/Dockerfile
# Start from a base Slackware 14.2 image (adjust if a better official base is found)
FROM vbatts/slackware:14.2
# Set the root password (replace 'yourpassword' with a strong one)
RUN echo 'root:yourpassword' | chpasswd
# Install OpenSSH
RUN slackpkg update && \
slackpkg install openssh
# Ensure sshd_config is present and configured for key or password auth
RUN if [ ! -f /etc/ssh/sshd_config ]; then \
cp /etc/ssh/sshd_config.example /etc/ssh/sshd_config; \
fi && \
sed -i 's/^#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
# Create ssh host keys
RUN ssh-keygen -A
# Expose the SSH port
EXPOSE 22
# Start the SSH server
CMD ["/usr/sbin/sshd", "-D"]
eof
## Architect slackware 15.0 image using docker file
cat <<'eof' > slackware150/Dockerfile
# Start from a base Slackware 15.0 image (adjust if a better official base is found)
FROM vbatts/slackware:15.0
# Set the root password (replace 'yourpassword' with a strong one)
RUN echo 'root:yourpassword' | chpasswd
# Install OpenSSH (use slackpkg or similar if available/needed)
RUN slackpkg update && \
slackpkg install openssh
# Ensure sshd_config is present and configured for key or password auth
RUN if [ ! -f /etc/ssh/sshd_config ]; then \
cp /etc/ssh/sshd_config.example /etc/ssh/sshd_config; \
fi && \
sed -i 's/^#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
# Create ssh host keys
RUN ssh-keygen -A
# Expose the SSH port
EXPOSE 22
# Start the SSH server
CMD ["/usr/sbin/sshd", "-D"]
eof
## Build images, create network, and run containers
docker compose up -d --build
## Verify everything is working
docker compose ps
docker exec -it slackware150_container netstat -plnt
docker exec -it slackware142_container netstat -plnt
## Test -- yourpassword
docker exec -it slackware142_container ssh root@slack150 'cat /etc/os-release ; echo $SSH_CONNECTION ; netstat -pnt'
docker exec -it slackware150_container ssh root@slack142 'cat /etc/os-release ; echo $SSH_CONNECTION ; netstat -pnt'
## Clean up
docker compose down
docker image rm slackwaressh-slackware142 slackwaressh-slackware150
cd .. && rm -rf slackware.ssh/
# docker system prune --volumes --force # uncomment to remove cached images
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment