Install Docker And Docker Compose

/ Comments off

Docker Compose is a tool for defining and running multi-container Docker applications. It allows users to launch, execute, communicate, and close containers with a single coordinated command. This guide will show you how to install Docker Compose on Ubuntu. Oct 01, 2021 After that, we can install docker and docker-compose using. Apk add docker docker-compose Step 3: Start & Enable docker service at boot. Enable autostart on boot using. Rc-update add docker default. Then you can start the docker service by running below command /etc/init.d/docker start. Now you have Alpine Linux installed with docker and docker.

Docker doesn’t need a graphical interface and it is best is to use the Raspbian Stretch Lite image and enable SSH. This way your Raspberry Pi will have much more available processing power and memory to run the Docker containers. Install Docker on Raspberry Pi # Installing Docker on Raspberry Pi is just a matter of running a few commands. # apt-get install docker docker-compose The packages will be installed in few seconds, and the docker service will be automatically started. We can now proceed into creating a directory for our project and inside of it, another one to hold the pages that will be served by Apache. Docker Compose is a tool used to define and run multi-container Docker applications. Users utilize this software to launch, execute, communicate, and close containers with a single coordinated command. This tutorial will show you how to install Docker Compose on CentOS 7.

Estimated reading time: 7 minutes

You can run Compose on macOS, Windows, and 64-bit Linux.

Prerequisites

Docker Compose relies on Docker Engine for any meaningful work, so make sure youhave Docker Engine installed either locally or remote, depending on your setup.

  • On desktop systems like Docker Desktop for Mac and Windows, Docker Compose isincluded as part of those desktop installs.

  • On Linux systems, first install theDocker Enginefor your OS as described on the Get Docker page, then come back here forinstructions on installing Compose onLinux systems.

  • To run Compose as a non-root user, see Manage Docker as a non-root user.

Install Compose

Follow the instructions below to install Compose on Mac, Windows, Windows Server2016, or Linux systems, or find out about alternatives like using the pipPython package manager or installing Compose as a container.

Install a different version

The instructions below outline installation of the current stable release(v1.29.2) of Compose. To install a different version ofCompose, replace the given release number with the one that you want. For instructions to install Compose 2.0.0 on Linux, see Install Compose 2.0.0 on Linux.

Compose releases are also listed and available for direct download on theCompose repository release page on GitHub.To install a pre-release of Compose, refer to the install pre-release buildssection.

Install Compose on macOS

Docker Desktop for Mac includes Compose alongwith other Docker apps, so Mac users do not need to install Compose separately.For installation instructions, see Install Docker Desktop on Mac.

Install Compose on Windows desktop systems

Docker Desktop for Windows includes Composealong with other Docker apps, so most Windows users do not need toinstall Compose separately. For install instructions, see Install Docker Desktop on Windows.

If you are running the Docker daemon and client directly on MicrosoftWindows Server, follow the instructions in the Windows Server tab.

Install docker and docker compose on mac

Install Compose on Windows Server

Follow these instructions if you are running the Docker daemon and client directlyon Microsoft Windows Server and want to install Docker Compose.

  1. Start an “elevated” PowerShell (run it as administrator).Search for PowerShell, right-click, and chooseRun as administrator. When asked if you want to allow this appto make changes to your device, click Yes.

  2. In PowerShell, since GitHub now requires TLS1.2, run the following:

    Then run the following command to download the current stable release ofCompose (v1.29.2):

Note: On Windows Server 2019, you can add the Compose executable to $Env:ProgramFilesDocker. Because this directory is registered in the system PATH, you can run the docker-compose --version command on the subsequent step with no additional configuration.

  1. Test the installation.

Install Compose on Linux systems

On Linux, you can download the Docker Compose binary from theCompose repository release page on GitHub.Follow the instructions from the link, which involve running the curl commandin your terminal to download the binaries. These step-by-step instructions arealso included below.

For alpine, the following dependency packages are needed:py-pip, python3-dev, libffi-dev, openssl-dev, gcc, libc-dev, rust, cargo and make.

  1. Run this command to download the current stable release of Docker Compose:

    To install a different version of Compose, substitute 1.29.2with the version of Compose you want to use.

    If you have problems installing with curl, seeAlternative Install Options tab above.

  2. Apply executable permissions to the binary:

Note: If the command docker-compose fails after installation, check your path.You can also create a symbolic link to /usr/bin or any other directory in your path.

For example:

  1. Optionally, install command completion for thebash and zsh shell.

  2. Test the installation.

Alternative install options

Install using pip

For alpine, the following dependency packages are needed:py-pip, python3-dev, libffi-dev, openssl-dev, gcc, libc-dev, rust, cargo, and make.

Compose can be installed frompypi using pip. If you installusing pip, we recommend that you use avirtualenv because many operatingsystems have python system packages that conflict with docker-composedependencies. See the virtualenvtutorial to getstarted.

If you are not using virtualenv,

pip version 6.0 or greater is required.

Install as a container

Compose can also be run inside a container, from a small bash script wrapper. Toinstall compose as a container run this command:

Install pre-release builds

If you’re interested in trying out a pre-release build, you can download releasecandidates from the Compose repository release page on GitHub.Follow the instructions from the link, which involves running the curl commandin your terminal to download the binaries.

Pre-releases built from the “master” branch are also available for download athttps://dl.bintray.com/docker-compose/master/.

Pre-release builds allow you to try out new features before they are released,but may be less stable.

Upgrading

If you’re upgrading from Compose 1.2 or earlier, remove ormigrate your existing containers after upgrading Compose. This is because, as ofversion 1.3, Compose uses Docker labels to keep track of containers, and yourcontainers need to be recreated to add the labels.

If Compose detects containers that were created without labels, it refusesto run, so that you don’t end up with two sets of them. If you want to keep usingyour existing containers (for example, because they have data volumes you wantto preserve), you can use Compose 1.5.x to migrate them with the followingcommand:

Alternatively, if you’re not worried about keeping them, you can remove them.Compose just creates new ones.

Uninstallation

To uninstall Docker Compose if you installed using curl:

To uninstall Docker Compose if you installed using pip:

Docker

Got a “Permission denied” error?

If you get a “Permission denied” error using either of the abovemethods, you probably do not have the proper permissions to removedocker-compose. To force the removal, prepend sudo to either of the abovecommands and run again.

Where to go next

compose, orchestration, install, installation, docker, documentation

With the dockerized OTOBO deployment you can get your personal OTOBO instance up and running within minutes.All of OTOBO´s dependencies are already included in the provided collection of Docker images.

  • MariaDB is set up as the default database.
  • Elasticsearch is set up for the OTOBO power search.
  • Redis is enabled for fast caching.
  • Gazelle is used as fast Perl webserver.
  • nginx is used as optional reverse proxy for HTTPS support.

We think that this setup will become the perfect environment for an OTOBO installation.

Requirements¶

The minimal versions of required software, that have been tested, are listed here:

  • Docker 19.03.13
  • Docker Compose 1.25.0
  • Git 2.17.1

Note

To get the required minimal versions on Ubuntu 18.04 follow the instructions inhttps://www.digitalocean.com/community/tutorials/how-to-install-docker-compose-on-ubuntu-18-04and https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-18-04.

git, Docker, and Docker Compose can be installed with the standard system tools.Here is an example for installation on Ubuntu 20.04:

Please check the Git and the Docker documentation for instructions on further setup.

Installation¶

The following instructions assume that all requirements are met, that you have a working Docker environment.We assume here that the user docker_admin is used for interacting with Docker. The Docker admin may be eitherthe root user of the Docker host or a dedicated user with the required permissions.

1. Clone the otobo-docker repo¶

The Docker images will eventually be fetched from the repository https://hub.docker.com.But there are some setup and command files that need to be cloned from the otobo-docker Github repository.Make sure that you specify the branch that corresponds to the current version of OTOBO.For example, when OTOBO 10.0.12 is the current version then please use the branch rel-10_0.

Note

The location of the cloned repository does not matter.For these instructions we chose /opt/otobo-docker as the working dir.

2. Create an initial .env file¶

The Docker Compose configuration file .env is your primary interface for managing your installation of OTOBO.This file must first be created and then be adapted by yourself. In order to simplify the task thereare several example files that should be used as starting point.Which sample file it the best fit depends on your use case. In most cases the decision is between.docker_compose_env_http and .docker_compose_env_https, depending on whether TLS must be supported or not.The other files are for more specialised use cases.

.docker_compose_env_http
The OTOBO web app provides HTTP.
.docker_compose_env_https
The OTOBO web app provides HTTPS by runnning Nginx as a reverse proxy webserver.
.docker_compose_env_https_custom_nginx
Like .docker_compose_env_https but with support for a custom Ninx configuration.
.docker_compose_env_https_kerberos
Like .docker_compose_env_https but with sample setup for single sign on.
.docker_compose_env_http_selenium and .docker_compose_env_https_selenium
These are used only for development when Selenium testing is activated.

Per default OTOBO is served on the standard ports. Port 443 for HTTPS and port 80 for HTTP.When HTTPS is activated then the OTOBO web application actually still runs with HTTP. HTTPS supportis achieved by an additional reverse proxy, which is implemented as a nginx service.

For the following commands we assume that HTTPS should be supported.

3. Configure the password for the database admin user¶

Change the following setting inside your .env file:

OTOBO_DB_ROOT_PASSWORD=<your_secret_password>

The password for the database admin user may be chosen freely. The database admin user is needed tocreate the database user otobo and the database schema otobo. OTOBO will actually use the dedicateddatabase user otobo.

4. Set up a volume with SSL configuration for the nginx webproxy (optional)¶

This step can be skipped when OTOBO should be available only via HTTP.

nginx needs for SSL encryption a certificate and a private key.

Note

For testing and development a self-signed certificate can be used. However for productive use you shouldwork with regular registered certificates.

See e.g. https://www.digitalocean.com/community/tutorials/how-to-create-a-self-signed-ssl-certificate-for-nginx-in-ubuntu-18-04on how to create self-signed certificates.

Note

To specify a CA chain with a certificate in nginx, it is necessary to copy the CA chain filewith the actual certificate into a file.

The certificate and the private key are stored in a volume, so that they can be used by nginx later on.In any case the volume needs to be generated manually, and we need to copy the certificate and key to the volume:

The names of the copied files need to be set in our newly created .env file. E.g.

OTOBO_NGINX_SSL_CERTIFICATE=/etc/nginx/ssl/ssl-cert.crt andOTOBO_NGINX_SSL_CERTIFICATE_KEY=/etc/nginx/ssl/ssl-key.key

Please adapt only the name of the files as the path /etc/nginx/ssl/ is hard coded in the Docker image.

5. Start the Docker containers with Docker Compose¶

Now we start the Docker containers using docker-compose. Per default the Docker images will befetched from https://hub.docker.com/u/rotheross.

To verify that the six required services (five in the case of HTTP only) are actually running, type:

6. Install and start OTOBO¶

Run the OTOBO installer at http://yourIPorFQDN/otobo/installer.pl.

Note

Please configure OTOBO inside the installer with a new MySQL database.As MySQL database root password please use the password you configuredin the variable OTOBO_DB_ROOT_PASSWORD of your .env file.Please leave the value db for the MySQL hostname untouched.

Have fun with OTOBO!

Note

To change to the OTOBO directory, inside the running container, to work on command line as usual, you can use the following Docker command:dockerexec-itotobo_web_1bash.

Additional technical information¶

This section gives some more technical insight into what is happing under the hood.

List of Docker containers¶

Container otobo_web_1
OTOBO webserver on internal port 5000.
Container otobo_daemon_1
OTOBO daemon. The OTOBO daemon is started and periodically checked.
Container otobo_db_1
Run the database MariaDB on internal port 3306.
Container otobo_elastic_1
Elasticsearch on the internal ports 9200 and 9300.
Container otobo_redis_1
Run Redis as caching service.
Optional container otobo_nginx_1
Run nginx as reverse proxy for providing HTTPS support.

Overview over the Docker volumes¶

The Docker volumes are created on the host for persistent data.These allow starting and stopping the services without losing data. Keep in mind thatcontainers are temporary and only data in the volumes is permanent.

otobo_opt_otobo
contains /opt/otobo in the container web and daemon.
otobo_mariadb_data
contains /var/lib/mysql in the container db.
otobo_elasticsearch_data
contains /usr/share/elasticsearch/datal in the container elastic.
otobo_redis_data
contains data for the container redis.
otobo_nginx_ssl
contains the TLS files, certificate and private key, must be initialized manually.

Docker environment variables¶

In the instructions we did only minimal configuration. But the file .env allows to setmore variables. Here is a short list of the most important environment variables.Note that more environment variables are supported by the base images.

MariaDB settings

OTOBO_DB_ROOT_PASSWORD
The root password for MySQL. Must be set for running otobo db.

Elasticsearch settings

Elasticsearch needs some settings for productive environments. Please readhttps://www.elastic.co/guide/en/elasticsearch/reference/7.8/docker.html#docker-prod-prerequisitesfor detailed information.

OTOBO_Elasticsearch_ES_JAVA_OPTS
Example setting:OTOBO_Elasticsearch_ES_JAVA_OPTS=-Xms512m -Xmx512mPlease adjust this value for production env to a value up to 4g.

Webserver settings

OTOBO_WEB_HTTP_PORT
Set in case the HTTP port should deviate from the standard port 80.When HTTPS is enabled, the HTTP port will redirect to HTTPS.

nginx webproxy settings

These setting are used when HTTPS is enabled.

OTOBO_WEB_HTTP_PORT
Set in case the HTTP port should deviate from the standard port 80.Will redirect to HTTPS.
OTOBO_WEB_HTTPS_PORT
Set in case the HTTPS port should deviate from the standard port 443.
OTOBO_NGINX_SSL_CERTIFICATE
SSL cert for the nginx webproxy.Example: OTOBO_NGINX_SSL_CERTIFICATE=/etc/nginx/ssl/acme.crt
OTOBO_NGINX_SSL_CERTIFICATE_KEY
SSL key for the nginx webproxy.Example: OTOBO_NGINX_SSL_CERTIFICATE_KEY=/etc/nginx/ssl/acme.key

Docker Compose settings

These settings are used by Docker Compose directly.

COMPOSE_PROJECT_NAME
The project name is used as the prefix for the volumes and containers. Per default this prefix is set tootobo, resulting in container names like otobo_web_1 and otobo_db_1. Change this name when you want to runmore then one instance of OTOBO on the same server.
COMPOSE_PATH_SEPARATOR
Separator for the value of COMPOSE_FILE
COMPOSE_FILE
Use docker-compose/otobo-base.yml as the base and add the wanted extension files.E.g docker-compose/otobo-override-http.yml or docker-compose/otobo-override-https.yml.
OTOBO_IMAGE_OTOBO, OTOBO_IMAGE_OTOBO_ELASTICSEARCH, OTOBO_IMAGE_OTOBO_NGINX, …
Used for specifying alternative Docker images. Useful for testing local builds or for using updated versions of the images.

Advanced topics¶

Custom configuration of the nginx webproxy¶

The container otobo_nginx_1 provides HTTPS support by running Nginx as a reverse proxy.The Docker image that runs in the containeris composed of the official Nginx Docker image, https://hub.docker.com/_/nginx, along witha OTOBO specific configuration of Nginx.

The default OTOBO specific configuration can be found within the Docker image at/etc/nginx/template/otobo_nginx.conf.template. Actually, this is only a template for the final configuration.There is a process, provided by the Nginx base image, that replacesthe macros in the template with the corresponding environment variable. This process runs when the container starts up.In the default template file, the following macros are used:

OTOBO_NGINX_SSL_CERTIFICATE
For configuring SSL.
OTOBO_NGINX_SSL_CERTIFICATE_KEY
For configuring SSL.
OTOBO_NGINX_WEB_HOST
The internally used HTTP host.
OTOBO_NGINX_WEB_PORT
The internally used HTTP port.

See step 4. for how this configuration possibility was used for setting up the SSL certificate.

Warning

The following approach is only supported in OTOBO 10.0.4 or later.

When the standard macros are not sufficient, then the customisation can go further.This can be achieved by replacing the default config template with a customized version. It is best practice tonot simple change the configuration in the running container. Instead we first create a persistent volume that containsthe custom config. Then we tell the otobo_nginx_1 to mount the new volume and to use the customized configuration.

First comes generation of the new volume. In these sample commands, we use the existing template as a starting point.

Warning

Your adapted nginx configuration usually contains the directive listen, which declares the ports of the webserver.The internally used ports have changed between OTOBO 10.0.3 and OTOBO 10.0.4. This change must be reflected in theadapted nginx configuration. So for version 10.0.3 or earlier listen to the ports 80 and 443. For OTOBO 10.0.4 listento the ports 8080 and 8443.

After setting up the volume, the adapted configuration must be activated. The new volume is set up indocker-compose/otobo-nginx-custom-config.yml. Therefore this file must be added to COMPOSE_FILE.Then Nginx must be directed to use the new config. This is done by setting NGINX_ENVSUBST_TEMPLATE_DIR in the environment.In order to achieve this, uncomment or add the following lines in your .env file:

The changed Docker Compose configuration can be inspected with:

Finally, the containers can be started again:

See also the section “Using environment variables in nginx configuration (new in 1.19)” in https://hub.docker.com/_/nginx.

Install Docker And Docker Compose Raspberry Pi

Choosing non-standard ports¶

Per default the ports 443 and 80 serve HTTPS and HTTP respectively. There can be cases where one or both of these portsare already used by other services. In these cases the default ports can be overridden by specifyingOTOBO_WEB_HTTP_PORT and OTOBO_WEB_HTTPS_PORT in the .env file.

Customizing the OTOBO Docker image¶

Many customizations can be done in the external volume otobo_opt_otobo which corresponds to the directory /opt/otoboin the Docker image. This works e.g. for local Perl modules, which can be installed into /opt/otobo/local.The advantage of this approach is that the image itself does not have to be modified.

Install Docker And Docker Compose On Mac

Installing extra Debian packages is a little bit trickier. One approach is to create a custom Dockerfileand use the OTOBO image as the base image. Another approach is to create a modified image directly from a runningcontainer. This can be done with the command docker commit, https://docs.docker.com/engine/reference/commandline/commit/.A nice writeup of that process is available at https://phoenixnap.com/kb/how-to-commit-changes-to-docker-image.

But for the latter approach there are two hurdles to overcome. First, the image otobo runs per default as the user otobowith the UID 1000. The problem is that the user otobo is not allowed to install system packages.Thus, the first part of the solution is to pass the option –user root when running the image.However the second hurdle is that the default entrypoint script /opt/otobo_install/entrypoint.shexits immediately when it is called as root. The reasoning behind that design decision is thatrunning inadvertently as root should be discouraged. So, the second part of the solution is to specifya different entrypoint script that does not care who the caller is.This leaves us with following example commands, where we add fortune cookies to otobo:

Pull a tagged OTOBO image, if we don’t have it yet, and check whether the image already provides fortune cookies:

Add fortune cookies to a named container running the original OTOBO image. This is done in an interactivesession as the user root:

Create an image from the stopped container and give it a name.Take into account that the default user and entrypoint script must be restored:

Finally we can doublecheck:

Compose

The modified image can be specified in your .env file and then be used for fun and profit.

Building local images¶

Note

Building Docker images locally is usually only needed during development.Other use cases are when more current base images should be used for an installationor when extra functionality must be added to the images.

The Docker files needed for creating Docker images locally are part of the the git repository https://github.com/RotherOSS/otobo:

Install Docker And Docker Compose For Windows

  • otobo.web.dockerfile
  • otobo.nginx.dockerfile
  • otobo.elasticsearch.dockerfile

The script for the actual creation of the images is bin/docker/build_docker_images.sh.

The locally built Docker images are tagged as local-<OTOBO_VERSION> using the version set up the file RELEASE.

After building the local images, one can return to the docker-compose directory. The local images are declared by settingOTOBO_IMAGE_OTOBO, OTOBO_IMAGE_OTOBO_ELASTICSEARCH, OTOBO_IMAGE_OTOBO_NGINX in .env.

Automatic Installation¶

Instead of going through http://yourIPorFQDN/otobo/installer.pl, one can take a short cut. This is useful forrunning the test suite on a fresh installation.

Warning

docker-composedown-v will remove all previous setup and data.

List of useful commands¶

Docker

  • dockersystemprune-a system clean-up (removes all unused images, containers, volumes, networks)
  • dockerversion show version
  • dockerbuild--tagotobo--file=otobo.web.Dockerfile. build an image
  • dockerrun--publish80:5000otobo run the new image
  • dockerrun-it-vopt_otobo:/opt/otobootobobash log into the new image
  • dockerrun-it-vopt_otobo:/opt/otobo--entrypointbashotobo try that in case entrypoint.sh is broken
  • dockerps show running images
  • dockerimages show available images
  • dockervolumels list volumes
  • dockervolumeinspectotobo_opt_otobo inspect a volume
  • dockervolumeinspect--format'{{.Mountpoint}}'otobo_nginx_ssl get volume mountpoint
  • dockervolumermtmp_volume remove a volume
  • dockerinspect<container> inspect a container
  • dockersave--outputotobo.tarotobo:latest&&tar-tvfotobo.tar list files in an image
  • dockerexec-itnginx-servernginx-sreload reload nginx

Docker Compose

  • docker-composeconfig check and show the configuration
  • docker-composeps show the running containers

Resources¶