"docker run -p" assigned the localhost IP but did not effect on Macos - macos

I use the following command to create a container on MacOS,my docker version is "Docker for Mac",
docker run -itd --name dns-mysql1 --network=host -p 192.168.43.178:53:53 brilliance/dns-mysql:latest
but when it starts,it does not affect,the mapped port and IP address has changed,
As follows:
but it does work on Ubuntu or other Linux system. I want to know why.

Related

How do I retrieve the IP of a windows host from a docker container?

I am trying to obtain the true IP address of a windows host running a docker container, not the ip address of the bridge. Windows system is using WSL
The following works on a linux host, but not on a windows host.
Create a simple container:-
docker run --rm -d --network host --name test alpine tail -f /dev/null
connect into the container:-
docker exec -it test /bin/sh
run ifconfig
On Linux I can see the true host IP address listed (10.0.0.2)
On windows the host ip address isnt present, but other adapters are.

Serving web page with Docker using custom /etc/host on host machine

I have added a host/ip to my macbook pro's /etc/hosts file. So something like:
192.168.0.0 example.test
What I would like to do is run a web server with Docker that utilizes the hostname, instead of 'localhost'
I can't figure out how to make this work. I have a laravel project running, and can make it serve to localhost with Docker via:
php artisan serve --host=0.0.0.0
I have tried using the --add-host flag with Docker's run command when I start the container. So something like:
docker container run -it -p 80:80 -v $(pwd)app --add-host example.test:192.168.0.0 my-custom-container bash
Any help would be greatly appreciated. I am pretty stuck.
The --hostname argument provides the hostname of the container itself.
docker container run --hostname example.test -it -p 80:80 -v $(pwd)app --add-host example.test:192.168.0.0 my-custom-container bash
Example:
$ docker run -it debian
root#2843ba8b9de5:/# hostname
2843ba8b9de5
root#2843ba8b9de5:/# exit
$ docker run -it --hostname foo.example.com debian
root#foo:/# hostname
foo.example.com
root#foo:/#

How to access the docker VM (MobyLinux) filesystem from windows shell?

Is there away to log into host VM's shell, similarly to how can we easily enter into running containers bash?
docker exec -it bash
I accidentally broke one container's crucial file, so that it couldn't start. Unfortunately, that container stored it's data inside. The result was that whenever I tried to run it, it couldn't start. The only solutions I saw were about navigating to host docker daemon's files. However, I'm running docker VM on windows, and I cannot access the files inside VM (MobyLinuxVM).
I'm using Docker for Windows, version 1.12.3-beta30.1 (8711)
Hack your way in
run a container with full root access to MobyLinuxVM and no seccomp profile (so you can mount stuff)
docker run --net=host --ipc=host --uts=host --pid=host -it --security-opt=seccomp=unconfined --privileged --rm -v /:/host alpine /bin/sh
https://forums.docker.com/t/how-can-i-ssh-into-the-betas-mobylinuxvm/10991/6

Connecting to rethinkdb (or any other app running on an http port) from the Docker OS X beta

I've installed the Docker for Mac beta which allows you to use docker commands directly. I want to try to run rethinkdb through docker, so I've followed the instructions of the rethinkdb docker container docs and done the following:
docker run --name some-rethink -v "$PWD:/data" -d rethinkdb
This works, and I can see the container with docker ps and start shell with docker exec -it /bin/bash
However, I can't connect to the admin panel on my Mac directly with their suggestion
$BROWSER "http://$(docker inspect --format \
'{{ .NetworkSettings.IPAddress }}' some-rethink):8080"
This essentially amounts to google-chrome http://172.17.0.2:8080/, but this doesn't work. I asked around and was told
You can't use the docker private ip address space to access the ports
You have to forward them to the mac
However, I'm not sure how to do this as I don't have any port forwarding tools I'm familiar with such as ssh on the container itself. Using the suggested port forwarding command in the rethinkdb container docs ssh -fNTL ... but with localhost instead of remote does not work.
How can I connect to the rethinkdb admin panel through http with the docker beta on a Mac?
Try forwarding the container port using the -p flag in the docker run command, e.g.:
docker run -p 8080:8080 --name some-rethink -v "$PWD:/data" -d rethinkdb
and then it should be accessible on localhost,
google-chrome http://127.0.0.1:8080/
Relevant docker run docs: https://docs.docker.com/engine/reference/run/#/expose-incoming-ports

Can't access docker-machine IP on Windows

I'm using Docker Terminal on Windows running a container from my nginx image and when I access the docker-machine IP on my browser I get "CONNECTION_REFUSED".
This is command that I used to run the container
docker run -it -d -v /home/user/html:/usr/share/nginx/html -p 80:80 myimage
Check if your container is running (docker ps)
Log in your container to see if there is any error log (docker exec -it container_name /bin/bash)
Make sure you are using correct IP address (docker-machine ip container_name)
It's very important to check logs with docker logs <container name>
After that, you'll see if connection refused is due to a
Address visibility problem.
NginX configuration problem.
Port 80 is already being used.
...

Resources