Skip to content

Run Docker Container

DBeaverDevOps edited this page Jun 19, 2024 · 34 revisions

Table of contents

Docker repositories

CloudBeaver container images are on DockerHub:

Product Docker repository URL
CloudBeaver EE dbeaver/cloudbeaver-ee https://hub.docker.com/r/dbeaver/cloudbeaver-ee
CloudBeaver AWS dbeaver/cloudbeaver-aws https://hub.docker.com/r/dbeaver/cloudbeaver-aws
CloudBeaver Community dbeaver/cloudbeaver https://hub.docker.com/r/dbeaver/cloudbeaver

Each image has following tags:

Tag Description
latest The latest stable product release
22.1.2, 23.0.1, etc Exact product version
ea Early Access version
devel Development version, unstable

Examples:

  • dbeaver/cloudbeaver-ee:23.0.0 - CloudBeaver EE version 23.0
  • dbeaver/cloudbeaver-aws:ea - CloudBeaver AWS Early Access version
  • dbeaver/cloudbeaver:latest - latest community release

Notes:

  • We will use repository cloudbeaver-ee as an example in the following instructions. Replace it with proper product repository (see above).
  • To run docker commands your user must be in proper user group or run it as root (e.g. sudo docker ps).

Installation

To install the latest version of CloudBeaver use the following script:

docker pull dbeaver/cloudbeaver-ee:latest

Running

To run Cloudbeaver in the terminal:

docker run --name cloudbeaver-ee --rm -ti -p 8080:8978 -v /opt/cloudbeaver/workspace dbeaver/cloudbeaver-ee:latest

Then switch to the browser and open http://localhost:8080/

Daemon mode

Add the following parameters:

-d --restart unless-stopped 

Accessing databases on the localhost

If you need to access the database server on the host machine, add the following parameter in docker run: (on Linux only)

 --network host

Cloudbeaver will work in the host machine network.
If this mode is not suitable for your network environment then you can run the container in the following way:

export CB_LOCAL_HOST_ADDR=$(ifconfig | grep -E "([0-9]{1,3}\.){3}[0-9]{1,3}" | grep -v 127.0.0.1 | awk '{ print $2 }' | cut -f2 -d: | head -n1)

docker run --name cloudbeaver --rm -ti -p 8080:8978 --add-host=host.docker.internal:${CB_LOCAL_HOST_ADDR} -v /opt/cloudbeaver/workspace dbeaver/cloudbeaver-ee:latest

or just run script deploy/docker/run-docker-container.sh. It passes the IP address of host machine to the container.

Docker parameters explanation

Parameters explanation:

Parameter Explanation
--name cloudbeaver Assign container ID (cloudbeaver)
--rm Removes container on stop
-ti Enables terminal mode (allows to stop container with CTRL+C)
-p 8080:8978 Maps CloudBeaver public port (8978) to the host machine port (e.g. 8080)
-v /opt/cloudbeaver/workspace Mounts local folder /var/cloudbeaver/workspace to the server workspace as Docker volume. Required to keep CloudBeaver data after container restart. For Example:
-v /var/cloudbeaver/workspace:/opt/cloudbeaver/workspace
-v $HOME/cloudbeaver/workspace:/opt/cloudbeaver/workspace
--add-host=host.docker.internal:IP address Adds host name in the container's /etc/hosts file. This may be needed to access the database server deployed on the host machine.
dbeaver/cloudbeaver-ee:latest Container ID

Run Cloudbeaver server with non-root user

If you want to run CloudBeaver with a non-root user, you have to build your own image with a user inside before the container starts.

Create Dockerfile which contains:

FROM dbeaver/cloudbeaver-ee:latest
RUN groupadd cloudbeaver
RUN useradd -ms /bin/bash -g cloudbeaver cloudbeaver
RUN chown -R cloudbeaver ./
USER cloudbeaver

Run this command to build the image from Dockerfile

docker build -t my-cloudbeaver .

To run CloudBeaver in the terminal:

docker run --name cloudbeaver --rm -ti -p 8080:8978 -v /opt/cloudbeaver/workspace my-cloudbeaver

Offline install

On a host with no internet access you need to download and archive image:

Note: <TAG> is a tag name for docker image (see above). latest is the default.

docker pull dbeaver/cloudbeaver-ee:<TAG>
docker save dbeaver/cloudbeaver-ee:<TAG> | gzip > cloudbeaver-ee.latest.tar.gz

Check that the archive exist:

ls -lah

Output should looks like:

-rw-r--r-- 1 user users 444M may 5 17:32 cloudbeaver-ee.latest.tar.gz

Now copy file cloudbeaver-ee.latest.tar.gz to some external drive and put to server with running cloudbeaver server.

Load image from archive:

docker load < cloudbeaver-ee.latest.tar.gz

You will see next output

Loaded image: dbeaver/cloudbeaver-ee:<TAG>

Upgrade your cloudbeaver-ee server:

docker stop cloudbeaver-ee
docker rm cloudbeaver-ee
docker run -d --restart unless-stopped -p 8978:8978 -v /opt/cloudbeaver/workspace dbeaver/cloudbeaver-ee:<TAG>

Note: some of docker args may differ from your environment.

How to change the base docker image

Create a new Dockerfile with the following content:

FROM alpine:latest

RUN apk update && apk add bash

ENV JAVA_HOME=/opt/java/openjdk
COPY --from=eclipse-temurin:17-alpine $JAVA_HOME $JAVA_HOME
ENV PATH="${JAVA_HOME}/bin:${PATH}"

ENV CLOUDBEAVER_HOME="/opt/cloudbeaver"
COPY --from=dbeaver/cloudbeaver:latest $CLOUDBEAVER_HOME $CLOUDBEAVER_HOME

WORKDIR "/opt/cloudbeaver"

RUN chmod +x run-server.sh

ENTRYPOINT ["./run-server.sh"]

The dockerfile above creates an image of the latest CloudBeaver CE based on Alpine.

  • To change the OS:
    • Replace the base image on the first line.
    • Adapt the RUN apk update && apk add bash line to work with the package manager of your OS.
    • If you're changing the base OS from musl-based (like Alpine) to glibc-based (like Debian or Fedora), change the tag for eclipse-temurin from 17-alpine to 17.
  • To change CloudBeaver edition or version, change the dbeaver/cloudbeaver:latest value to a more appropriate one.

Build a new image with:

docker build -t cloudbeaver-<edition>:<your_tag> .

Now, you can push the new image to your registry or run the CloudBeaver server.

CloudBeaver Documentation

User Guide

Installation

Configuration

CloudBeaver AWS

CloudBeaver Enterprise Edition

Team Edition

Deployment

Clone this wiki locally