DEV Community

Cover image for How to Install Docker on Ubuntu for Development
Russell Jones
Russell Jones

Posted on • Edited on

How to Install Docker on Ubuntu for Development

Docker is an essential tool for developing web applications with Laravel and most other projects. It allows you to create and run isolated containers that contain everything you need to run your code.

To install Docker on Ubuntu, start by running the following command in our terminal to download and execute the Docker installation step.

curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
Enter fullscreen mode Exit fullscreen mode

Verify that Docker is installed correctly by running:

docker --version
Enter fullscreen mode Exit fullscreen mode

You should see something like this:

Docker version 20.10.8, build 3967b7d
Enter fullscreen mode Exit fullscreen mode

Adding the User to the Docker Group

To run docker commands without sudo, you need to add your user account to the docker group. This will also prevent permission errors when working with docker files and directories.

To add your user to the docker group, follow these steps:

  • Create the docker group if it doesn't exist:
sudo groupadd docker
Enter fullscreen mode Exit fullscreen mode
  • Add your user to the docker group, replacing $USER with your username:
sudo usermod -aG docker $USER
Enter fullscreen mode Exit fullscreen mode
  • Log out and log back in for the changes to take effect. Alternatively, you can run this command to activate the changes:
newgrp docker
Enter fullscreen mode Exit fullscreen mode
  • Verify that you can run docker commands without sudo:
docker run hello-world
Enter fullscreen mode Exit fullscreen mode

You should see a message saying "Hello from Docker!" This means that you have successfully added your user to the docker group.

You have successfully installed Docker on Ubuntu. You can now create and run containers for your Laravel projects.

Next, we will use DDEV to make Laravel development easier in Docker.

Top comments (0)