docker run -d -p 5000 -v /tmp/registry:/tmp/registry --name="docker-registry" registry
docker push <docker-registry-ip>:5000/ubuntu
Resulting in the error:
FATA[0000] Error: v1 ping attempt failed with error: Get http://<docker-registry-ip>:5000/v1/_ping: dial tcp <docker-registry-ip>:5000: connection refused
I have already added below to /etc/default/docker and restarted docker service
DOCKER_OPTS="$DOCKER_OPTS --insecure-registry=<docker-registry-ip>:5000"
You did not bind the port on the host. When you only mention -p 5000, it is for the container port, and binds to a random port on the host. You will need to run:
docker run -d -p 5000:5000 -v /tmp/registry:/tmp/registry --name="docker-registry" registry
Also don't forget to tag the image first before you push it:
docker tag Ubuntu <docker-registry-ip>:5000/ubuntu
Related
I start my docker container with:
docker run -it --expose 10001 --expose 8080 -p 10001:10001 -p 8080:8080 -p 80:80 --rm lucchi/covid90/100e
My docker -ps then has:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1521e0c3d947 lucchi/covid90/100e "/bin/sh -c /bin/bash" 2 seconds ago Up Less than a second 0.0.0.0:80->80/tcp, 0.0.0.0:8080->8080/tcp, 0.0.0.0:10001->10001/tcp funny_panini
But I can't connect to localhost from inside the container. I tried:
curl 0.0.0.0:8080
curl 127.0.0.1:8080
curl https://localhost:8080
but keep getting
curl: (7) Failed to connect to localhost port 8080: Connection refused
Most of the asnwers I read are about adding -p to the run command, I don't get what I'm missing.
Are you trying to connect inside the container?
If not, you may fight this other unrelated question (covering the outside container case) helpful:
From inside of a Docker container, how do I connect to the localhost of the machine?
Is the a server process running inside the docker on the specified port ?
If the app logs are enabled you can get the logs of the container by executing the below command.
docker logs <container_name>
Additionally for ensuring if the app is up and running fine, try doing a curl
from inside of the docker container. You can use the docker exec command to execute any command inside the container.
I have "Docker for Windows" on my machine Windows 10.
I start selenium grid with docker as below:
docker run -d --name my-hub selenium/hub
docker run -d --name my-firefox -e HUB_HOST=my-hub -v c:/seleniumplus:/dev/seleniumplus selenium/node-firefox
docker run -d --name my-chrome -e HUB_HOST=my-hub -v c:/seleniumplus:/dev/seleniumplus selenium/node-chrome
I get the IP address of container "my-firefox" and "my-chrome", they are 172.17.0.3 and 172.17.0.4
docker inspect -f "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" my-firefox
docker inspect -f "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" my-chrome
I can ping the IP 172.17.0.3 and 172.17.0.4 from the docker host (my machine Windows 10).
I run a socket server on container "my-firefox" at port 9876, then I try to make a socket connection to the server by creating new Socket(172.17.0.3, 9876) from the docker host (my machine Windows 10), this fails with error
Exception in thread "main" java.net.ConnectException: Connection timed out: connect
Does anyone know what is wrong with it? How can get it work? I don't want to use the port-forwarding, yes we can map the container's port 9876 to the docker host's port (for example 9876) as below:
docker run -d -p 9876:9876 --name my-firefox -e HUB_HOST=my-hub -v c:/seleniumplus:/dev/seleniumplus selenium/node-firefox
Then we can make the connection by new Socket("localhost", 9876)
By the way, I make some other tests:
I run a socket server on container "my-firefox" at port 9876, then I try to make a socket connection to (172.17.0.3, 9876) from the other container "my-chrome" (172.17.0.4) and it succeeds.
I run a socket server on docker host (my machine Windows 10 whose IP is 172.27.20.204) at port 9876, then I try to make a socket connection to (172.27.20.204, 9876) from a container ("my-chrome" or "my-firefox") and it succeeds.
Desciption: I am trying to connect my sql metastore of hive from python script on local machine.I am using docker image of cloudera quickstart to hadoop package.I am even exposing the my sql port(9083) while running the cloudera container but still it is not working.Am I exposing the port correctly or I need to do something else too
I am running the cloudera container using below command
docker run --hostname=quickstart.cloudera --privileged=true --publish-all=true --expose 9083 -t -i -p 8888:8888 -p 80:80 -p 7180:7180 -p 9083:9083 cloudera/quickstart /usr/bin/docker-quickstart
I am trying below python command to connect to the mysql db of cloudera docker image
db = pymysql.connect(host="127.0.0.1",
port="9083",# your host, usually localhost
user="hive", # your username
passwd="cloudera",
db="metastore"
) # name of the data base
Getting below error
Operational Error: (2003, "Can't connect to MySQL server on '127.0.0.1' ([Win Error 10061] No connection could be made because the target machine actively refused it)")
Expected Result:
Python script should get connected to the mysql metastore db of hive
You have to specify the Host IP address in MySQL string connection if you are trying to connect to external MySQL. Here 127.0.0.1 point to localhost of the container, not the HOST.
Change your docker command and set the HOST IP in the container.
docker run --add-host hostdb:HOST_IP --hostname=quickstart.cloudera --privileged=true --publish-all=true --expose 9083 -t -i -p 8888:8888 -p 80:80 -p 7180:7180 -p 9083:9083 cloudera/quickstart /usr/bin/docker-quickstart
Now update the MySQL connection string and set the host to hostdb
db = pymysql.connect(host="hostdb", # this will point to IP that we set in docker run command
port="9083",# your host, usually localhost
user="hive", # your username
passwd="cloudera",
db="metastore"
)
Managing /etc/hosts
Your container will have lines in /etc/hosts which define the hostname
of the container itself as well as localhost and a few other common
things. The --add-host flag can be used to add additional lines to
/etc/hosts.
docker run reference
I want to run a docker container that has no access to the outside internet. I've been using --network=none for this successfully. But now I want to host a web server from that container, and access it from outside. When I try, I find that the port mapping is totally ignored:
$ docker run --rm -it -p 8000:8000 --network=none python bash
# python -m http.server
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...
Now from outside the container:
$ docker port 981f253788ad
$ curl localhost:8000
curl: (7) Failed to connect to localhost port 8000: Connection refused
You can try using a custom network with --internal option and then attaching your container to this network:
$ docker network create --internal internal-network
$ docker run --rm -it -p 8000:8000 --network=internal-network python bash
I am beginner and just started using docker, before posting here I google a lot but a lot of mixed confusing result.
I started docker with this command
docker run -itd --name dockWeb2 -v /var/www/wordpress/ -p 80:80 atozchevara/rpi-apache-php5
hoping I would be able to directly mount wordpress installation onto container , as by default it picks internal path of container /var/www/index.php, to override it I used -v flag. but it doesn't work.
I tried using multiple ports by passing -p arguments again for each port but that too gives error
docker run -itd --name dockWeb3 -v /var/www/wordpress/ -p 80:80 -p 22:22 atozchevara/rpi-apache-php5
66a959e4e99af8122705913005fcae12e2e8a5203da7b77ff1717751314fca28
docker: Error response from daemon: driver failed programming external connectivity on endpoint dockWeb3 (eb42a619a8c79961d35d59e0d8930a92541a20132525055afb3b0d2d87483e7f): Bind for 0.0.0.0:80 failed: port is already allocated.
otherwise Could have uploaded my wordpress using ssh to container's /var/www/ location.
For the first issue if you want to mount a volume from the host you need to use Bind mount a volume
docker run -itd --name dockWeb2 -v your_project_path:/var/www/wordpress/ 0.0.0.0:80 failed: port is already allocated. atozchevara/rpi-apache-php5
For the post using -p 80:80 you are publishing container port 80 to the host port 80, and if the host port is already in use you got an error 0.0.0.0:80 failed: port is already allocated. try to use a different port -p 9090:80.