In Container

EasyEngine in Contianer – Deploy Anywhere

Creating an EasyEngine container, allowing you to deploy and use EasyEngine on any Linux distribution, not just the officially supported Debian/Ubuntu.

It works well with systems like:

  • CentOS, RHEL, AlmaLinux
  • Arch, OpenSUSE, Fedora
  • Minimal/container-focused OSes like: Fedora CoreOS, OpenSUSE Leap Micro, Alpine, etc.

System Requirements

Docker must be installed and running

Check if Docker is installed:

docker version

If not, follow the official guide: 👉 https://docs.docker.com/get-docker/

How to Deploy

Run the following command to launch the EasyEngine container:

docker run -it --rm --privileged \
  -v /var/run/docker.sock:/var/run/docker.sock:z \
  -v /var/lib/docker/volumes:/var/lib/docker/volumes \
  -v /opt/easyengine:/opt/easyengine \
  -v /etc/localtime:/etc/localtime:ro \
  --network host \
  --name ee-container \
  dinhngocdung/easyengine:latest

Explanation of Parameters:

ParameterDescription
--privilegedAllows the container to interact with Docker on the host
--rmAutomatically removes the container when it exits
-v /var/run/docker.sockGrants access to Docker daemon from within the container
-v /opt/easyengineStores EasyEngine configs and website data persistently on the host
--network hostEnsures services like web/db run properly with host networking
-v /etc/localtime:..Sync time with host

How to Use

Once inside the container (ee-container), you can use EasyEngine commands as usual.

Example Commands:

ee site create example.com --type=wp
ee site list
ee site disable example.com
ee site delete example.com

To exit the container, type:

exit

This will return you to the host OS and the container will be automatically removed. However, all your EasyEngine data and websites remain intact on the host under /opt/easyengine.

Reusing EasyEngine

Whenever you need to use EasyEngine, just rerun the docker run debloy command to launch a new container environment instantly.

Sync/Clone

Sync/Clone is designed for interaction between EasyEngine installations directly on the host. For these commands to work with ee-container, you need the following:

Local ee-container

  1. Use a dedicated connection key, different from the main key, to access the host to ensure host control is maintained.
    ssh-keygen -t ed25519 -f ~/.ssh/id_ee_container
    ssh-copy-id -i ~/.ssh/id_ee_container.pub YOUR-USER@YOUR-REMOTE-SERVER.com
    ssh -i ~/.ssh/id_ee_container YOUR-USER@YOUR-REMOTE-SERVER.com
  2. Use the new ssh-key in the local ee-container:
    # Temporarily copy to ee-container
    sudo cp ~/.ssh/id_ee_container /opt/easyengine/
    
    # Use the ssh-key
    cp /opt/easyengine/id_ee_container ~/.ssh/id_ed25519

If using EasyEngine directly on host:

  echo "Host YOUR-REMOTE-SERVER.com
      HostName YOUR-REMOTE-SERVER.com
      User YOUR-USER
      IdentityFile ~/.ssh/id_ee_container
      IdentitiesOnly yes" >> ~/.ssh/config

Remote ee-containerr Host

  1. Create a bash Script /usr/local/bin/ssh_to_ee_container.sh to forward ssh and rsync commands:
    #!/bin/bash
    
    # Name of the Docker container you want to connect to
    CONTAINER_NAME="ee-container"
    
    # Check if a command was passed via SSH_ORIGINAL_COMMAND
    if [ -n "$SSH_ORIGINAL_COMMAND" ]; then
        docker exec -i "$CONTAINER_NAME" /bin/bash -c "$SSH_ORIGINAL_COMMAND"
    else
        if [ -n "$SSH_TTY" ]; then
            docker exec -it "$CONTAINER_NAME" /bin/bash
        else
            docker exec -i "$CONTAINER_NAME" /bin/bash
        fi
    fi
  2. Edit ~/.ssh/authorized_keys on the remote host to run ssh_to_ee_container.sh when access by ssh-key:
    vi ~/.ssh/authorized_keys
    Insert command="/usr/local/bin/ssh_to_ee_container.sh" beford ssh-...
    command="/usr/local/bin/ssh_to_ee_container.sh" ssh-ed25519 AAAAB3NzaC1yc2EAAAADAQABAAABAQ... your_key_comment_or_email

Reference

Last updated on