Is it possible to access mptcp sysctl inside docker? - docker

I would like to access sysctl -n net.mptcp.mptcp_enabled from docker container, but currently I couldn't achieve it. I already tried the below things.
1.
docker run -d --sysctl net.mptcp.mptcp_enabled=1 --name=test -p 3100:3100 my_container
75dcbdc65a1539ce734a413cb6e23bf216aea76f6533c52280d3e866270424b9
docker: Error response from daemon: failed to create shim: OCI runtime create failed: container_linux.go:380: starting container process caused: process_linux.go:545: container init caused: write sysctl key net.mptcp.mptcp_enabled: open /proc/sys/net/mptcp/mptcp_enabled: no such file or directory: unknown.
docker run -d --cap-add=SYS_ADMIN --privileged --name=test -p 3100:3100 my_container
This time container starts but there is no file under /proc/sys/net/mptcp/mptcp_enabled
3.
docker run -d -v /proc:/proc --cap-add=SYS_ADMIN --privileged --name=test -p 3100:3100 my_container
This is also the same as 2.
I saw that a sysctl that starts with net.* are namespaced but wonder why this is not working.
Note: My host machine has mptcp supported kernel and I can see all mptcp related files under /proc/sys/net/mptcp/*

I faced the same issue. Using --net=host should solve it.
Try this:
docker run -d --net=host --name=test -p 3100:3100 my_container

Related

How to get access to the docker cmd from docker container?

I've tried to get access to docker command from a container I got an issue says that
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
the container created using this CMD line :
sudo docker run -p 8080:8080 -p 50000:50000 -v /var/run/docker.sock:/usr/lib/systemd/system/docker.socket --name jenkins-master -d jenkins
Hey Guys the issue was in the socket volume I mean in this section
-v /var/run/docker.sock:/usr/lib/systemd/system/docker.socket
should be change to
-v /var/run/docker.sock:/var/run/docker.sock

Pass configuration file to mosquitto in Docker container

Trying to run masquitto Docker container on Windows. I have directory structure:
..
mosquitto
config
-- mosquitto.conf
data
log
I run command:
docker run -it -p 1883:1883 -p 9001:9001 -v mosquitto.conf:/mosquitto/config/mosquitto.conf -v /mosquitto/data -v /mosquitto/log eclipse-mosquitto
Got error:
docker: Error response from daemon: source /var/lib/docker/overlay2/c54f317f73085489398e1b2c4ffbc85fbdb18073e8a0fa60f11a7f7222fbc49d/merged/mosquitto/config/mosquitto.conf is not directory.
See 'docker run --help'.
What I do wrong?
UPD
I tried to provide full path to config file on host machine:
docker run -it -p 1883:1883 -p 9001:9001 -v C:/docker_tst/eclipse-mosquitto/mosquitto.conf:/mosquitto/config/mosquitto.conf eclipse-mosquitto
Got error:
docker: Error response from daemon: OCI runtime create failed: container_linux.go:370: starting container process caused: process_linux.go:459: container init caused: rootfs_linux.go:59: mounting "/run/desktop/mnt/host/c/docker_tst/eclipse-mosquitto/mosquitto.conf" to rootfs at "/var/lib/docker/overlay2/d9a7cbcb0f85b195dc5ee2d0999b3df8c84324552f6c45cf218876e9b96ed826/merged/mosquitto/config/mosquitto.conf" caused: not a directory: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type.
PS C:\docker_tst\eclipse-mosquitto>
From the comments, the solution was to provide an absolute path to the single mounted file, per this answer.
On Unix based systems or in Windows Subsystem for Linux, you can do this by running something like:
docker run -v $PWD/filename:/path/in/container IMAGE_NAME
However, the process is different on Windows, per this answer.
In PowerShell, you can run Get-Location or pwd to get the current directory where your file is and switch the \ to / (forward slashes). For this example, the solution was to use this command:
docker run -it -p 1883:1883 -p 9001:9001 -v C:/docker_tst/eclipse-mosquitto/mosquito/config/mosquito.conf:/mosquitto/config/mosquitto.conf eclipse-mosquitto

Command with 2 paths when running a docker container

Hey I'm very new at this so bear with me please.
I'm trying to run a docker container I exported. The container was running with command:
I've tried using this:
sudo docker run -p 8080:8080 --name=test testcontainer --entrypoint=/sbin/tini -- /usr/local/bin/jenkins.sh
However I get errors:
docker: Error response from daemon: OCI runtime create failed: container_linux.go:345: starting container process caused "exec: \"--entrypoint=/sbin/tini\": stat --entrypoint--/sbin/tini: no such file or directory": unknown.
I've also tried a combination of them with a space between them like such:
sudo docker run -p 8080:8080 --name=test testcontainer --entrypoint=/sbin/tini /usr/local/bin/jenkins.sh
How would i go about to running that command?
--entrypoint would go before the image name
sudo docker run -p 8080:8080 --name=test --entrypoint=/sbin/tini testcontainer /usr/local/bin/jenkins.sh
The extra arguments would follow that to become the command (and dashes aren't needed.
Or if bash is the default entrypoint, you can give the whole thing as a command.
sudo docker run -p 8080:8080 --name=test testcontainer bash -c "/sbin/tini -- /usr/local/bin/jenkins.sh"

Can we run docker inside a docker container which is running in a virtual-box of Ubuntu 18.04?

I want to run docker inside another docker container. My main container is running in a virtualbox of OS Ubuntu 18.04 which is there on my Windows 10. On trying to run it, it is showing me as:
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
How can I resolve this issue?
Yes, you can do this. Check for dind (docker in docker) on docker webpage how to achieve it: https://hub.docker.com/_/docker
Your error indicates that either dockerd in the top level container is not running or you didn't mount docker.sock on the dependent container to communicate with dockerd running on your top-level container.
I am running electric-flow in a docker container in my Ubuntu virtual-box using this docker command: docker run --name efserver --hostname=efserver -d -p 8080:8080 -p 9990:9990 -p 7800:7800 -p 7070:80 -p 443:443 -p 8443:8443 -p 8200:8200 -i -t ecdocker/eflow-ce. Inside this docker container, I want to install and run docker so that my CI/CD pipeline in electric-flow can access and use docker commands.
From your above description, ecdocker/eflow-ce is your CI/CD solution container, and you just want to use docker command in this container, then you did not need dind solution. You can just access to a container's host docker server.
Something like follows:
docker run --privileged --name efserver --hostname=efserver -d -p 8080:8080 -p 9990:9990 -p 7800:7800 -p 7070:80 -p 443:443 -p 8443:8443 -p 8200:8200 -v $(which docker):/usr/bin/docker -v /var/run/docker.sock:/var/run/docker.sock -i -t ecdocker/eflow-ce
Compared to your old command:
Add --privileged
Add -v $(which docker):/usr/bin/docker, then you can use docker client in container.
Add -v /var/run/docker.sock:/var/run/docker.sock, then you can access host's docker daemon using client in container.

dockerd[1455]: time="2017-12-18T19:08:30.299677811+03:00" level=error msg="stream copy error: reading from a closed fifo"

I'm calling host docker command line utility from inside of docker container on Ubunty via making it available inside container with volume by passing the host binaries, lib and unix socket when calling docker run as volumes like that:
-v /var/run/docker.sock:/var/run/docker.sock \
-v /usr/bin/docker:/usr/bin/docker \
-v /usr/lib/x86_64-linux-gnu/libltdl.so.7:/usr/lib/x86_64-linux-gnu/libltdl.so.7
Then inside container I'm calling:
docker run --rm - --hostname registrator_notificator_222444 -it -P -d \
-e CONSUL_1=172.17.0.3:8301 mycontainername:5043/app/myappname /etc
and then getting the error:
dockerd[1455]: time="2017-12-18T19:08:30.299677811+03:00" level=error msg="stream copy error: reading from a closed fifo"
What is fifo said in the error?
The problem was with wrong last parameter in the docker run call:
docker run --rm --hostname registrator_notificator_222444 -it -P -d -e CONSUL_1=172.17.0.3:8301 mycontainername:5043/app/myappname /etc
is was a typo and had no sence; it was leading for such error

Resources