Sujan Tuladhar
Sujan Tuladhar's Blog

Follow

Sujan Tuladhar's Blog

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

Photo by Rubaitul Azad on Unsplash

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

Sujan Tuladhar's photo
Sujan Tuladhar
·Mar 2, 2023·

1 min read

  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.

 
Share this