Install Docker And Docker Compose On Ubuntu 18.04

Install Docker Compose from Ubuntu's repository. This is the easiest and recommend method. Unless you need the latest Docker Compose version for some specific reasons, you can manage very well with the docker compose version provides by Ubuntu. Docker Compose is available in the universe repository of Ubuntu 20.04 and 18.04 so make sure to. Sep 08, 2020 Here, let’s discuss how Support Engineers install docker-compose on Ubuntu. Before proceeding to install docker-compose, it mandatory to install docker on the sever. Initially, we update Software Repositories and Packages using the below commands. Apt-get upgrade. Then, we download the latest Docker Compose Version. In this tutorial, we’ll install the Docker Compose from the official Docker’s GitHub repository and not the one from Ubuntu repositories. This is because the Docker Compose application from GitHub repository is the latest release and is ideally suited for Ubuntu 18.04. Run the command below to install the current release of Docker Compose.

In an effort for setting development tools in the most economical way (and also learn stuff about as much as possible), I am now trying to install docker-compose on a fresh Ubuntu 18.04 instance.

At the end, an nginx is supposed to run at startup and display a generic page.

Assumpions

  • the OS is already installed;
  • ufw is enabled, ports 80 and 443 are accesible;
  • the OS already has a custom user with sudo privileges (e.g. user);
  • we have a domain name pointing at the IP of the server (e.g. example.com) and also a CNAME record (*.example.com);

Install docker

  • sudo apt update
  • sudo apt install -y apt-transport-https ca-certificates curl software-properties-common
  • curl -fsSL https://download.docker.com/linux/ubuntu/gpg sudo apt-key add -
  • sudo add-apt-repository
    'deb [arch=amd64] https://download.docker.com/linux/ubuntu
    $(lsb_release -cs)
    stable'
  • sudo apt update
  • sudo apt upgrade -y
  • apt-cache policy docker-ce
  • sudo apt install docker-ce
  • sudo systemctl status docker
  • sudo usermod -aG docker ${USER}
  • su - ${USER}
  • id -nG
Docker-compose download

Install docker-compose

  • sudo curl -L https://github.com/docker/compose/releases/download/1.23.2/docker-compose-uname -s-uname -m -o /usr/local/bin/docker-compose
  • sudo chmod +x /usr/local/bin/docker-compose
  • docker-compose --version

Setup Nginx

  • sudo mkdir -p /app
  • cd /app
  • sudo touch docker-compose.yml
  • sudo nano docker-compose.yml

Install Docker Compose On Ubuntu 18.04 Lts

  • docker-compose up -d
  • Access http://example.com and here you should see the default nginx page.

Autostart

  • crontab -e
    You can use crontab -u <username> -e to execute the following command as a specific user;
  • add: @reboot (sleep 60 ; su user -c 'cd /app ; /usr/local/bin/docker-compose down ; /usr/local/bin/docker-compose -f docker-compose.yml up -d --build')&
  • sudo reboot
  • http://example.com should still be accesible after server starts;
  • http://whatever.example.com should also be aviable, with the same content.

Docker-compose Download

Docker

Sources

And

Install Docker And Docker Compose On Ubuntu 18.04ntu 18 04

  • https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-18-04
  • https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-18-04
  • https://www.digitalocean.com/community/tutorials/how-to-install-docker-compose-on-ubuntu-18-04
  • https://github.com/docker/compose/releases
  • https://stackoverflow.com/questions/43671482/how-to-run-docker-compose-up-d-at-system-start-up
  • https://askubuntu.com/questions/612928/how-to-run-docker-compose-at-bootup
  • https://blog.cloud66.com/10-tips-for-docker-compose-hosting-in-production/
  • https://www.digitalocean.com/community/tutorials/how-to-set-up-laravel-nginx-and-mysql-with-docker-compose