SoFunction
Updated on 2025-03-10

How to install strongswan in docker container

1. Start a ubuntu container. I started it with docker compose. The configuration file of compose is

services:
  ipsec-strongswan:
    image: ubuntu:22.04
    container_name: ipsec-strongswan
    cap_add:
      - NET_ADMIN
      - SYS_ADMIN
      - SYS_MODULE
    command: "tail -f /dev/null" # Example: Keep the container running, but won't do anything actual    volumes:
      - /opt/services/ipsec-strongswan/:/etc/
      - /opt/services/ipsec-strongswan/:/etc/
      - /opt/services/ipsec-strongswan/USERTrust_RSA_Certification_Authority.pem:/etc//cacerts/USERTrust_RSA_Certification_Authority.pem
      - /opt/services/ipsec-strongswan/:/etc//
      - /opt/services/ipsec-strongswan/log:/var/log/strongswan
    #Port is for 3proxy    ports:
      - 1180:1080
networks:
  default:
    name: sill
sudo docker compose -f  up -d

2. Enter the container

sudo docker exec -it ipsec-strongswan /bin/bash

3. Start the installation

apt-get update
apt-get install strongswan libcharon-extra-plugins

Install some common software

apt-get install vim iputils-ping curl mtr

My configuration is already loaded in the compose file, so it doesn't work. Start directly

# Start ipsecipsec restart
# Connection uk2ipsec up uk2

If the connection is successful, the connection ‘uk2’ was established successfully
View status

ipsec statusall

Stop the connection

ipsec down uk2

Stop ipsec

ipsec stop

Here are some other commands:
View the network

ip addr show   Abbreviation as ip a s

View the docker service's network

sudo docker inspect -f '{{.Name}}: {{}}{{.IPAddress}}{{end}}' nginx jenkins rmqnamesrv mysql rmqbroker rocketmq-console redis6379 redis6380 redis6381 sentinel26379 sentinel26380 sentinel26381 ipsec-strongswan

View host routes

ip route show

Attached Install 3proxy

sudo docker cp /home/ubuntu/Downloads/3proxy-0.9.4.x86_64.deb ipsec-strongswan:/usr/local

References

ubuntu installation load 3proxy

This is the end of this article about installing strongswan in ubuntu in docker container. For more related content on installing strongswan in docker container, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!