How to Run Docker-Compose up Without Root Privilages?

I want to run docker-compose up as non-root user. When I execute:

sudo docker-compose up

it works great, but when I execute:

docker-compose up

an error is shown:

 TITLE>Network Error</TITLE>
</HEAD>
<BODY>
<FONT face="Helvetica">
<big><strong></strong></big><BR>
</FONT>
<blockquote>
<TABLE border=0 cellPadding=1 width="80%">
<TR><TD>
<FONT face="Helvetica">
<big>Network Error (tcp_error)</big>
<BR>
<BR>
</FONT>
</TD></TR>
<TR><TD>
<FONT face="Helvetica">
A communication error occurred: ""
</FONT>
</TD></TR>
<TR><TD>
<FONT face="Helvetica">
The Web Server may be down, too busy, or experiencing other problems preventing it from responding to requests. You may wish to try again at a later time.
</FONT>
</TD></TR>
<TR><TD>
<FONT face="Helvetica" SIZE=2>
<BR>
For assistance, contact your network support team.
</FONT>
</TD></TR>
</TABLE>
</blockquote>
</FONT>
</BODY></HTML>

I have added user to docker group and docker commands work without sudo, however docker-compose is causing trouble.

2 Answers

One of the reasons is that the current user has not been added to the docker group. To check if the current user is in the docker group, we can use:

cat /etc/group | grep docker

If we do not see the current user in the output of the previous command, we will add it by using this command:

sudo gpasswd -a $USER docker

And lastly, we need to restart the docker service by using the command:

sudo service docker restart

I've found solution. The invalid proxy was set for non-root user. I've edited /etc/profile and now it works ok.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Sophia Al-Mansoor

Sophia Al-Mansoor

Global Business & E-Commerce Reporter

Sophia analyzes international trade, startup ecosystems, retail transformation, and supply chain logistics for modern digital publications.

Share this article
Twitter Facebook Pinterest