Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why am I getting an RTNETLINK Operation Not Permitted when using Pipework with Docker containers?

Tags:

docker

I'm running CoreOS stable 494.5.0 using Vagrant/VirtualBox and am running the vanilla ruby:2.1.5 Docker image. I'm trying to use Pipework to connect the Docker container to a local physical interface (as opposed to using --net=host when running the container) so I can sniff traffic. Pipework creates eth1@if2 in the container and sets its IP address correctly, but the link ends up in the UNKNOWN state and when I try to bring the link up using ip link I get RTNETLINK answers: Operation not permitted.

If it makes a difference, I have to use ip link set dev eth1 up instead of ip link set dev eth1@if2 up or else I get Cannot find device "eth1@if2".

Any ideas what I'm doing wrong?

like image 448
Bryan Avatar asked Dec 30 '14 15:12

Bryan


People also ask

Can you ssh into a running Docker container?

The SSH method works fine for Docker containers, too. That said, you can SSH into a Docker container using Docker's built-in docker exec . If you do not need an interactive shell, you can also use the docker attach command to connect the host's stdin and stdout to the running container and execute remote commands.

Can I run multiple services in a container?

It's ok to have multiple processes, but to get the most benefit out of Docker, avoid one container being responsible for multiple aspects of your overall application. You can connect multiple containers using user-defined networks and shared volumes.

Which Docker command is used to attach to a running container?

Use docker attach to attach your terminal's standard input, output, and error (or any combination of the three) to a running container using the container's ID or name. This allows you to view its ongoing output or to control it interactively, as though the commands were running directly in your terminal.

Why can't I run a docker container with full privileges?

Docker containers do not have full privileges by default. Try adding this to the docker run command: Credit where credit is due: this answer is based on a comment by @petrkotek under the accepted answer, but I ended up using it myself, so I wanted to make it more visible. Thanks for contributing an answer to Stack Overflow!

Does the TC command work on a dockerfile?

The tc command works on a regular vm, but not in the Dockerfile. FROM ubuntu:16.04 RUN DEBIAN_FRONTEND="noninteractive" \ apt-get update --fix-missing && \ apt-get -y install \ apt-utils \ software-properties-common \ iproute2 RUN tc qdisc add dev lo root handle 1: htb docker build .

Why not use a docker image instead of a docker container?

Docker doesn't have fully virtualized networking and a container can't usually control its network environment in this level of detail; also an image is only a filesystem plus some metadata describing how to start the container, and runtime settings like this aren't persisted in the image. I'd stick with a VM here.


2 Answers

Docker containers do not have full privileges by default. Try adding this to the docker run command:

--cap-add=NET_ADMIN 

List of capabilities

like image 179
user2105103 Avatar answered Sep 27 '22 21:09

user2105103


In your docker-compose.yml you can add this:

container_or_service_name:   cap_add:     - NET_ADMIN 

Credit where credit is due: this answer is based on a comment by @petrkotek under the accepted answer, but I ended up using it myself, so I wanted to make it more visible.

like image 40
Alex Shroyer Avatar answered Sep 27 '22 20:09

Alex Shroyer