To install the latest version of Docker on a Debian 12 server, follow these steps:
### 1. Update the Apt Package Index
First, update your existing list of packages:
sudo apt update
### 2. Install Prerequisite Packages
Install packages that allow `apt` to use repositories over HTTPS:
sudo apt install apt-transport-https ca-certificates curl gnupg lsb-release
### 3. Add Docker’s Official GPG Key
Add Docker’s official GPG key:
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
### 4. Set Up the Docker Repository
Add the Docker repository to your `apt` sources:
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
### 5. Update the Package Index Again
Update the package index with the new repository:
sudo apt update
### 6. Install Docker Engine
Install the latest version of Docker Engine, containerd, and Docker Compose:
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
### 7. Verify the Installation
Verify that Docker is installed correctly by running the `hello-world` image:
sudo docker run hello-world
This command downloads a test image and runs it in a container. When the container runs, it prints a confirmation message.
### 8. (Optional) Manage Docker as a Non-Root User
To avoid using `sudo` with Docker commands, add your user to the `docker` group:
sudo usermod -aG docker $USER
After adding yourself to the `docker` group, you’ll need to log out and log back in for the changes to take effect.
### 9. Enable and Start Docker
Enable Docker to start on boot and start the Docker service:
sudo systemctl enable docker
sudo systemctl start docker
### Troubleshooting
If you encounter any issues, check the Docker service status:
sudo systemctl status docker
This process installs the latest Docker Engine on your Debian 12 server, allowing you to manage containers effectively.
Installing WAHA (Core) Image
Pull the WAHA (Core) Docker image from the official repository.
sudo docker pull devlikeapro/waha
Running WAHA Core
Now that we have the WAHA Core image, let's run it as a Docker container.
sudo docker run -it -p 3000:3000/tcp devlikeapro/waha
Running WAHA (Plus) Image
sudo docker login -u devlikeapro -p dckr_pat_5e3AH5dtylfP5Bex5TJS8MD_0Os
sudo docker pull devlikeapro/waha-plus
sudo docker logout
sudo docker run -it -p 3000:3000/tcp devlikeapro/waha-plus
### With custom username and password
sudo docker run -it -p 3000:3000/tcp -e WAHA_DASHBOARD_USERNAME=maheshpalamuttath -e WAHA_DASHBOARD_PASSWORD=Msh94@664972 devlikeapro/waha-plus
Configuring Apache
To make our WAHA instance accessible via a domain name, we'll set up Apache as a reverse proxy.
Install Apache and enable required modules:
sudo apt update && sudo apt install -y apache2 && sudo a2enmod proxy proxy_http proxy_balancer lbmethod_byrequests && sudo systemctl reload apache2 && sudo systemctl restart apache2
sudo vim /etc/apache2/sites-available/000-default.conf
<VirtualHost *:80>
ServerName api-whats.opensio.co.in
ProxyPreserveHost On
# ProxyPass for backend WAHA server
ProxyPass / http://127.0.1.1:3000/
ProxyPassReverse / http://127.0.1.1:3000/
</VirtualHost>
sudo systemctl reload apache2 && sudo systemctl restart apache2
Optional - Installing SSL Certificate
If you wish to secure your WAHA instance with SSL, you can use Let's Encrypt to obtain a free SSL certificate.
Install Certbot:
sudo apt-get install -y certbot python3-certbot-apache
Obtain SSL Certificate:
sudo certbot --apache -d api-whats.opensio.co.in
Reload Apache:
sudo systemctl reload apache2 && sudo systemctl restart apache2
Create a Systemd Service File:
Create a new systemd service file for the WAHA Core container:
sudo nano /etc/systemd/system/waha.service
Add the following content:
[Unit]
Description=WAHA Core Docker Container
Requires=docker.service
After=docker.service
[Service]
Restart=always
ExecStart=/usr/bin/docker run --rm -p 3000:3000 --name waha devlikeapro/waha
ExecStop=/usr/bin/docker stop waha
[Install]
WantedBy=multi-user.target
Reload Systemd to Apply the New Service:
sudo systemctl daemon-reload
Enable and Start the Service:
sudo systemctl enable waha.service
sudo systemctl start waha.service
Check the Status of the Service:
Verify that the service is running and will start on boot:
sudo systemctl status waha.service
====================================================================
Create a new systemd service file for the WAHA Plus container:
Find docker container ID
sudo docker ps -a
sudo vim /etc/systemd/system/waha-plus.service
[Unit]
Description=Docker Container for WAHA Plus
Requires=docker.service
After=docker.service
[Service]
Restart=always
ExecStart=/usr/bin/docker start -a 481a312bc502
ExecStop=/usr/bin/docker stop -t 2 481a312bc502
ExecStopPost=/usr/bin/docker rm -f 481a312bc502
[Install]
WantedBy=default.target
sudo systemctl daemon-reload
sudo systemctl enable waha-plus
sudo systemctl start waha-plus
sudo systemctl status waha-plus