Installing Lando and Docker for Drupal 8 on Ubuntu

Lando and Docker

Lando is a Docker based development tool, which is much faster than Vagrant-based tools, since processes are run in containers directly on the host machine.

The requirements on the host machine. Note that a database is not required:

  • Docker
  • Lando
  • PHP
  • Composer

Install Docker

Follow the instructions on these pages;

Fix missing ~/.docker/config.json file, from
# "$HOME/.docker/config.json -- If there is no such file (and/or folder) you can create it. For example"

# create folder
mkdir $HOME/.docker

# create config with empty object
echo "{}" > $HOME/.docker/config.json

Manage Docker as a non-root user

sudo chown "$USER":"$USER" /home/"$USER"/.docker -R
sudo chmod g+rwx "$HOME/.docker" -R

Install PHP
Ubuntu 16.04:

sudo apt-get install php7.0 php7.0-cli php7.0-common php7.0-curl php7.0-dom php7.0-gd php7.0-mbstring php7.0-mysql php7.0-sqlite3 php7.0-xml

Upgrading to PHP 7.2 on Ubuntu 16.04 (Running sudo apt-get install php7.1 will also install apache):

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get remove php7.0
sudo apt-get install php7.2-cli php7.2-common php7.2-curl php7.2-gd php7.2-mbstring php7.2-mysql php7.2-odbc php7.2-soap php7.2-sqlite3 php7.2-xml php7.2-intl

Ubuntu 18.04:

sudo apt-get install php7.2-cli php7.2-common php7.2-curl php7.2-gd php7.2-intl php7.2-mbstring php7.2-mysql php7.2-odbc php7.2-soap php7.2-sqlite3 php7.2-xml php7.2-zip

Update to PHP 7.3.

Install Lando

Follow the instructions on these pages;

# download Latest release

# install 
sudo dpkg -i lando-v3.0.0-beta.47.deb

# remove install file
rm lando-v3.0.0-beta.47.deb

Switch between Lando versions, or install a new version
To switch between Lando versions, or install a newer version, first clean up and delete old Docker containers (see "Extra Docker tips" below), then uninstall and remove the old version:

# uninstall Lando and delete config folder, the extra space before the "rm" command excludes the command from being added to your terminal history
sudo dpkg -P lando
 rm ~/.lando -rf

Next, install latest version of Lando (as of today v3.0.0-rc.22)

sudo dpkg -i lando-v3.0.0-rc.22.deb
rm lando-v3.0.0-rc.22.deb

It's possible to downgrade from RC to Beta-version with the same method. Note: You need to adjust the .lando.yml file to the new syntax for RC-version of Lando.

Install Composer

# check if /home/your_username/.local/bin is part of the registered PATH:

echo $PATH

# if not, add this line to ~/.bashrc

export PATH="~/.local/bin/:$PATH"

# make it take effect

source ~/.bashrc

Download the latest stable composer.phar manually, see also


# finish installation, and commands to check and update
mkdir ~/.local/bin/ # create folder if it doesn't exist
mv composer.phar ~/.local/bin/composer
chmod a+rx ~/.local/bin/composer # make executable
whereis composer
composer selfupdate

Drupal 8 in Lando Docker

# create and enter your dev-directory, for example in ~/dev folder
# NOTE: don't call it .lando! This is where Lando configuration is written
mkdir ~/dev
cd ~/dev

# create a Drupal project. Assumes that you have Composer installed.
composer create-project drupal-composer/drupal-project:8.x-dev drupaltest --stability dev --no-interaction --no-dev

# cd into the created directory.
cd drupaltest

# launch the interactive session.
lando init

# or just specify the Drupal 8 recipe.
lando init --recipe drupal8 --webroot web --name drupaltest

# show info
lando info

# start lando
lando start

# install Drupal with Drush
lando drush site-install --db-url=mysql://drupal8:drupal8@database/drupal8 --account-pass=content -y

# log into your new site
lando drush uli -l

# download Admin Toolbar module
# "--update-no-dev" excludes developer-specific packages from being downloaded
composer require --update-no-dev 'drupal/admin_toolbar'

# enable Admin Toolbar module
lando drush en admin_toolbar admin_toolbar_tools -y

# clear cache
lando drush cache-rebuild

# destroy the Lando app and delete the folder
lando destroy
cd ..
chmod -R 775 drupaltest && rm drupaltest -rf;

# add these aliases to your ~/.bashrc file to shorten "lando drush" commands
# activate with closing the terminal, source ~/.bashrc is not enough
alias drush='lando drush'


Define Drush columns
By default, Lando sets this at 256 columns, for better readability you can tweak this. Set globally in ~/.lando/config.yml:

  COLUMNS: '128'

Insert with this:

printf "appEnv:\n  COLUMNS: '128'" >> ~/.lando/config.yml

Set per project, in .lando.yml:

        COLUMNS: '128'

Check if it looks good by typing drush, or with this:

$ lando ssh -s appserver -c env | grep -i col

Working offline with Lando
By default, you can't start Lando without internet access, since it uses an online service to look up a DNS entry: "Lando accomplishes this with an actual ON THE INTERNET wildcard DNS entry that points all subdomains to localhost/ This means that if you lose your internet connection, you will not be able to visit your app at these addresses."

The solution is Working Offline or Using Custom Domains by adding your custom domain in your /etc/hosts file, like this:

# Get my `` domain to work offline

# If you have defined an extra domain

IMPORTANT: You will need to do a lando poweroff to apply these changes.

Extra Docker tips
Status and clean up and delete containers, for more info, see

# display all containers
docker ps --all --format "table {{.ID}}\t{{.Image}}\t{{.Command}}\t{{.CreatedAt}}\t{{.Status}}\t{{.Names}}"

# stop, remove and remove images 
docker kill $(docker ps -q)
docker rm $(docker ps -a -q)
docker rmi $(docker images -q)

# disable Docker from starting on boot
# check Docker status
sudo systemctl list-unit-files | grep -i docker

# result
docker.service                             enabled 
docker.socket                              enabled 

# disable Docker from starting on boot
sudo systemctl disable docker.service
sudo systemctl disable docker.socket

Fix VPN Docker IP conflict
Dockers default IP ranges at 172.17.* 172.18.* 172.19.* might conflict with your VPN, if it uses the same ranges.

Adding this to `/etc/docker/daemon.json` and restarting Docker updates both `docker0` and the bridges (like `br-eb18f822dc96`):


Remove unused Docker networks, if they conflict with VPN connection

docker network prune


$ ip addr | grep 172
    inet brd scope global docker0
    inet brd scope global br-c71a376aa530
    inet brd scope global br-9a2279ba5e4f
    inet brd scope global br-ff55447fdd53

Some suggest this in `daemon.json`, but it only updates the IP for `docker0`, but not the bridges:

  "bip" : ""

stop and start Docker again

sudo systemctl stop docker
sudo systemctl start docker