"Unlock the Full Potential of Docker: Run Docker-Compose without Sudo"

"A step-by-step guide to configure Docker and Docker-Compose to run without sudo on Ubuntu"

Table of contents

No heading

No headings in the article.

  1. Create a docker group if it doesn't already exist:
sudo groupadd docker
  1. Add your user to the docker group:
sudo usermod -aG docker $USER
  1. Log out and log back in to refresh your group membership.

  2. Test that you can run Docker commands without using sudo:

docker run hello-world

If you see output similar to the following, Docker is working correctly:

Hello from Docker!
This message shows that your installation appears to be working correctly.
  1. Change the ownership of the docker-compose binary and make it executable:
sudo chown root:docker /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
  1. Test that you can run docker-compose without using sudo:
docker-compose --version

If you see output similar to the following, docker-compose is working correctly:

docker-compose version 1.29.2, build 5becea4c

That's it! You can now use docker-compose without using sudo. Note that you may need to log out and log back in for the group membership changes to take effect.