10 Oct 2018

Basic developer environment for Ubuntu 18.04


Originally published on Medium.

This guide will assist in how to set up a basic developer environment in Ubuntu 18.04 with docker, npm, and a local wildcard domain.

I’ve had to set up an environment in Ubuntu recently for a new developer and found some great articles out there about setting up the different components, but I couldn’t find one that had everything I needed.



Bare Ubuntu 18.04 desktop environment, logged in as a user with sudo privileges. This guide used the VDI from osboxes.org.

Install Docker¹

By default docker commands need to be run as sudo. We’ll change this to allow you to execute docker commands without administrator privileges.

1) Update & upgrade

$ sudo apt update
$ sudo apt upgrade

2) Install the dependencies necessary to enable a new repository over HTTPS

$ sudo apt install apt-transport-https ca-certificates curl software-properties-common

3) Add Docker’s GPG key and Docker stable repository

$ 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" 

4) Install Docker

$ sudo apt update
$ sudo apt install docker-ce

5) Add user to docker group

$ sudo usermod -aG docker $USER

Log out and back in.

6) Run docker hello-world container

$ docker container run hello-world

Install Docker Compose²

Docker Composed is used for running multi-container docker applications.

Check the current release and update the command below if needed.

1) Install Docker Compose

$ sudo curl -L https://github.com/docker/compose/releases/download/1.23.0-rc1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose

2) Set the permissions

$ sudo chmod +x /usr/local/bin/docker-compose

Install NVM, Node & NPM

NVM allows you to easily manage your Node.js environment and even allows you to have multiple versions of it without the usual complexities.

Check the current release and update the command below if required

1) Install NVM

$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash

Close and reopen the terminal.

2) Install Node.js & NPM

$ nvm install node
$ nvm install npm

Configure local wildcard domain

Traditionally, local environments are set up on localhost. This environment will allow you to set up a wildcard subdomain of local.test which will allow domains like me.local.testdummy.local.testetc.local.test. We’ll use a tool called dnsmasq to accomplish this via the standard NetworkManager for Ubuntu 18.04.

1) Edit the NetworkManager config

$ sudo vi /etc/NetworkManager/NetworkManager.conf

file: /etc/NetworkManager/NetworkManager.conf


2) Let NetworkManager manage /etc/resolv.conf

$ sudo rm /etc/resolv.conf 
$ sudo ln -s /var/run/NetworkManager/resolv.conf /etc/resolv.conf

3) Configure the domain local.test

$ echo 'address=/.local.test/' | sudo tee /etc/NetworkManager/dnsmasq.d/local.test-wildcard.conf

4) Reload NetworkManager

$ sudo systemctl reload NetworkManager

Test the environment

Run the following command, you should get the same result as show in expected output.

tmp=$(docker --version) && echo "docker: $tmp" && \
tmp=$(docker-compose --version) && echo "docker-compose: $tmp" && \
tmp=$(nvm --version) && echo "nvm: $tmp" && \
tmp=$(node --version) && echo "node: $tmp" && \
tmp=$(npm --version) && echo "npm: $tmp" && \
tmp=$(dig google.com +short) && echo "google.com: $tmp" && \
tmp=$(dig local.test +short) && echo "local.test: $tmp" && \
tmp=$(dig random.local.test +short) && echo "random.local.test: $tmp"

Expected outcome

docker: Docker version 18.06.1-ce, build e68fc7a
docker-compose: docker-compose version 1.23.0-rc1, build 320e4819
nvm: 0.33.11
node: v10.11.0
npm: 6.4.1


  1. https://linuxize.com/post/how-to-install-and-use-docker-on-ubuntu-18-04/#install-docker-on-ubuntu
  2. https://linuxize.com/post/how-to-install-and-use-docker-on-ubuntu-18-04/#executing-the-docker-command-without-sudo

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.