smebberson / docker-alpine

Docker containers running Alpine Linux and s6 for process management. Solid, reliable containers.
MIT License
596 stars 186 forks source link

ping: permission denied (are you root?) #65

Closed markych96 closed 7 years ago

markych96 commented 8 years ago

Hello! Is that normal behaviour? what after creating container by command docker run -d smebberson/docker-alpine and then getting shell by docker exec -it [container_id] sh and send ping 172.17.0.1 i've got a error message

ping: permission denied (are you root?)

how can i solve this problem?

P.S. docker version 1.12.1

thank you

rbellamy commented 7 years ago

Force UID=0 (root) when starting the container:

docker exec -u 0 -it [container_id] sh
smebberson commented 7 years ago

@markych96, has @rbellamy helped you out here? Can I close this issue?

markych96 commented 7 years ago

-u 0 not helped but i think you can close issue, i think that error is caused by alpine os as a docker host system then i start alpine-s6-overlay on rancher host error was gone

smebberson commented 7 years ago

@markych96, okay, thanks.

michaeljs1990 commented 7 years ago

@smebberson I would like to request that this is reopen. In my case I am running a program that is running ping as the apache user. The service is started with a uid of 0 however the apache user is not able to run ping.

an easy fix is chmod u+s /bin/ping however I feel like this should be something that makes it's way upstream.

To reproduce you can do build this dockerfile https://github.com/michaeljs1990/phpipam/blob/dockerfile/Dockerfile and then exec into it make a lol.php file in the working dir and use this script.

<?php

exec('/bin/ping -c 5 -w 5 192.168.1.5 2>&1', $output);
var_dump($output);

and go go lol.php.

michaeljs1990 commented 7 years ago

P.S you will have to remove the chmod u+s /bin/ping which i just pushed to that dockerfile.

michaeljs1990 commented 7 years ago

ops sorry, got confused with what repo i was in. name doesn't help :P

six8 commented 6 years ago

I've ran into the same issue running an Alpine Docker image on an Alpine Docker host. Forcing UID 0 does not work either.

sujitas400 commented 4 years ago

Hello! Is that normal behaviour? what after creating container by command docker run -d smebberson/docker-alpine and then getting shell by docker exec -it [container_id] sh and send ping 172.17.0.1 i've got a error message

ping: permission denied (are you root?)

how can i solve this problem?

P.S. docker version 1.12.1

thank you

Add user: root in docker-compose file

tonyctp commented 2 years ago

i've ran into the same issues. and maybe you could try docker exec -it [container_id] --privileged sh all of things will be fine

yjqg6666 commented 1 year ago

Run the following command may resolve your issue. # apk add --no-cache iputils && addgroup $USER ping