Running Multilogin in a Docker container
Related articles
In this article, we've covered the process of creating and launching the latest version of Multilogin inside a Docker container. Docker allows you to package and deploy your application in a consistent and portable manner, making it easier to manage it across different environments.
By following the steps outlined here, you can use Docker to run Multilogin on your local machine, in a cloud environment, or on any system that supports Docker, providing flexibility and scalability for your web automation needs. Multilogin supports running in headless mode and can be run on remote hosts.
Before you start
Before following the instructions from this article, make sure that you have:
- A setup that allows you to create and run Docker containers: this could be a cloud service, a server, a virtual machine, or simply your own computer with Docker installed
- A Docker Hub account to download the necessary images for building your container (for example, a Linux distribution)
- A Multilogin account to use the application inside your container
Step 1: Installing Docker
If you haven't installed Docker yet, you can do so by following the official installation guide for your operating system:
Step 2: Building a Docker container
To build a Docker container, you'll need a Dockerfile in your project directory. This file defines your container's configuration. Here's an example Dockerfile:
# Use an official base image with a compatible OS
FROM ubuntu:22.04
# List of basic dependancies
RUN apt-get update && apt-get install -y ca-certificates fonts-liberation libasound2 libatk-bridge2.0-0 libatk1.0-0 libatspi2.0-0 libc6 libcairo2 libcups2 libcurl4 libdbus-1-3 libdrm2 libexpat1 libgbm1 libglib2.0-0 libgtk-4-1 libnspr4 libnss3 libpango-1.0-0 libu2f-udev libvulkan1 libx11-6 libxcb1 libxcomposite1 libxdamage1 libxext6 libxfixes3 libxkbcommon0 libxrandr2 wget xdg-utils
# Dependancies to install and launch Multilogin application
RUN apt-get update && DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install -y openjdk-18-jre-headless curl unzip openssh-client
# Set environment variables for Multilogin login
ENV ML_USERNAME="your_multilogin_username"
ENV ML_PASSWORD="your_multilogin_password"
# Install Multilogin app
RUN mkdir -p /opt/multilogin/
RUN cd /opt/multilogin/ && \
curl --location --fail --output multiloginapp-linux-x64-client "https://cdn-download.multiloginapp.com/multilogin/6.3.6/multilogin-6.3.6-1-linux_x86_64.zip" && \
unzip multiloginapp-linux-x64-client && \
chmod +x multiloginapp-linux-x64-client && \
rm multiloginapp-linux-x64-client && \
apt-get -y install ./multilogin.deb
# Copy our main run script into workdir
COPY ./run.sh /opt/Multilogin/
# Add permission to execute and run our script
RUN chmod +x /opt/Multilogin/run.sh
CMD bash /opt/Multilogin/run.sh
Additionally, you'll need a run.sh file placed in the same directory as your Dockerfile. This file is necessary to run Multilogin with login parameters because Dockerfile CMD instructions don't support them:
#!/bin/bash
echo "Multilogin account is $ML_USERNAME with password of length $ML_PASSWORD"
cd opt/Multilogin/headless
bash ./cli.sh -login -u "$ML_USERNAME" -p "$ML_PASSWORD"
bash ./headless.sh -port 35000
Xvfb
or other Linux utilities. You can include these configurations in your run.sh bash script to make it work.Step 3: Running a Docker container
To build a Docker container, ensure your Docker daemon is running, and then execute the following command in the directory containing your Dockerfile:
docker build -t multilogin-container .
To run it in your preferred environment, use the following command:
docker run -d --name multilogin-app -p <host_port>:<container_port> multilogin-container
Specify ports to link your host and Docker container for HTTP request access.