edit: other containers run normally. docker run hello-world works fine.
I am trying to run the latest nginx docker image. It hangs indefinitely. I have tried this on 2 separate fresh install ubuntu virtual machines. I have no idea how to proceed. Any help would be appreciated.
docker run nginx:latest
Unable to find image 'nginx:latest' locally
latest: Pulling from library/nginx
68ced04f60ab: Already exists
28252775b295: Already exists
a616aa3b0bf2: Already exists
Digest: sha256:2539d4344dd18e1df02be842ffc435f8e1f699cfc55516e2cf2cb16b7a9aea0b
Status: Downloaded newer image for nginx:latest
...
...and it hangs at the end.
and some netstat to verify that ports 80 and 443 are free.
sudo netstat -tulpn
[sudo] password for josh:
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 387/systemd-resolve
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 471/cupsd
tcp6 0 0 ::1:631 :::* LISTEN 471/cupsd
udp 0 0 127.0.0.53:53 0.0.0.0:* 387/systemd-resolve
udp 0 0 0.0.0.0:68 0.0.0.0:* 6179/dhclient
udp 0 0 0.0.0.0:631 0.0.0.0:* 685/cups-browsed
udp 0 0 0.0.0.0:46233 0.0.0.0:* 485/avahi-daemon: r
udp 0 0 0.0.0.0:5353 0.0.0.0:* 485/avahi-daemon: r
udp6 0 0 :::5353 :::* 485/avahi-daemon: r
udp6 0 0 :::35115 :::* 485/avahi-daemon: r
When you execute this command docker run nginx:latest you are actually running it in the attached mode which means
All the log from stdout and stderr will be printed out on the screen
If you exit the command using Ctrl + c or Cmd + c, the container will be stopped.
As a result, it seems like the command hangs because there is no log being printed out anymore.
You can try to run the following command instead
docker run -it -d \
--name nginx_container \
-p 80:80 \
-p 443:443 \
nginx:latest
Note that this command will create a running nginx container with the name nginx_container running in the background (detached mode). Running this command again will result in the complaint that The container name "/nginx_container" is already in use by container.
To stop and remove that container, run the following command
docker stop nginx_container
docker rm nginx_container
Related
This question already has answers here:
Cannot connect to Go GRPC server running in local Docker container
(3 answers)
Docker port expose issue, Recv failure: Connection reset by peer
(1 answer)
Deploying a minimal flask app in docker - server connection issues
(8 answers)
Closed 1 year ago.
I created an linux application in GO consisting of a service myappd and a client myapp. I implemented a TCP based IPC on port 12345 between service and client hence the client could communicate with the service. If I run both on one machine, everything works fine.
Now I want to containerize the service. Therefore I created a Dockerfile
FROM debian:buster
COPY ./src/* /home/
RUN chmod 777 /home/myappd
ENTRYPOINT /bin/bash /home/myapp_entrypoint.sh
with the entrypoint script
echo create log locations
mkdir /var/log/myappd
chmod 744 /var/log/myappd
touch /var/log/myappd/myappd.log
chmod 744 /var/log/myappd/myappd.log
cd /home/
./myappd
And build the image with
docker build -t myappd:latest .
Running the container with
docker run --rm --name myappd -itd -p 127.0.0.1:12345:12345 myappd:latest
Afterwards I check, if the service is running and if the port is exposed to the localhost
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4caf95e1bd72 myappd:latest "/bin/sh -c '/bin/ba…" 6 minutes ago Up 2 seconds 127.0.0.1:12345->12345/tcp myappd
$ sudo netstat -tulpn | grep LISTEN
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1/init
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 520/sshd
tcp 0 0 127.0.0.1:12345 0.0.0.0:* LISTEN 10673/docker-proxy
tcp6 0 0 :::111 :::* LISTEN 1/init
tcp6 0 0 :::22 :::* LISTEN 520/sshd
It is looking good for me. But when I start the client on localhost, the dial on port 12345 succeeds but each request on the port 12345 is responsed instantly with EOF and without any content. If I run the service locally the IPC can be reached on the port 12345 as expected
$ sudo netstat -tulpn | grep LISTEN
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1/init
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 520/sshd
tcp 0 0 127.0.0.1:12345 0.0.0.0:* LISTEN 13184/./myappd
tcp6 0 0 :::111 :::* LISTEN 1/init
tcp6 0 0 :::22 :::* LISTEN 520/sshd
Has anyone an idea why the IPC is working, when I run the service locally, but don't work if I run the service in a container?
Environment:
Macbook Pro: 10.13.6 (17G65) High Sierra
Docker Desktop: 2.4.0.0
Docker Engine: 19.03.13
Browser: Chrome Version 87.0.4280.88 (Official Build) (x86_64)
I can't get the JFrog Container Registry webapp to run.
I followed the instructions on their website here to run a local docker container. When I initially connect to http://127.0.0.1:8081/artifactory, I see a loading animation like this:
Then, it automatically redirects to http://127.0.0.1:8082/ui and gives an error:
"This site can’t be reached. 127.0.0.1 refused to connect."
If I try to go to http://127.0.0.1:8081/artifactory, it just goes back to http://127.0.0.1:8082/ui and fails again. I tried to use incognito and other browsers with the same result
I tried several docker run variants, but the simplest one I tried was:
$docker run --name JCR -d -p 8081:8081 -v /Users/username/git/artifactory/docker-registry:/var/opt/jfrog/artifactory docker.bintray.io/jfrog/artifactory-jcr:latest
I checked the docker container and it is running and listening on various ports:
$ netstat -tulpn | grep LISTEN
tcp 0 0 127.0.0.1:8091 0.0.0.0:* LISTEN 3693/java
tcp 0 0 127.0.0.1:8070 0.0.0.0:* LISTEN 3562/node
tcp 0 0 127.0.0.1:8040 0.0.0.0:* LISTEN 3693/java
tcp 0 0 0.0.0.0:8045 0.0.0.0:* LISTEN 3693/java
tcp 0 0 127.0.0.1:8046 0.0.0.0:* LISTEN 3274/jf-router
tcp 0 0 127.0.0.1:8047 0.0.0.0:* LISTEN 3274/jf-router
tcp 0 0 127.0.0.1:8015 0.0.0.0:* LISTEN 3693/java
tcp 0 0 127.0.0.1:8049 0.0.0.0:* LISTEN 3274/jf-router
tcp 0 0 0.0.0.0:8081 0.0.0.0:* LISTEN 3693/java
tcp 0 0 127.0.0.1:8086 0.0.0.0:* LISTEN 3422/jf-metadata
tcp6 0 0 :::8082 :::* LISTEN 3274/jf-router
UPDATE
This worked when using the below docker run command (new docker image URL)
docker run -d --name artifactory -p 8082:8082 -p 8081:8081 -v /Users/username/git/artifactory/docker-registry:/var/opt/jfrog/artifactory releases-docker.jfrog.io/jfrog/artifactory-jcr:latest
It looks like you followed the instructions for 6.x, which are not valid for 'latest', which is 7.x. You should follow the instructions for Docker for 7.x (https://www.jfrog.com/confluence/display/JFROG/Installing+Artifactory#InstallingArtifactory-DockerInstallation). The only difference is that you will need to change it from pointing to the PRO to JCR.
If you want a super quick and dirty way to just get it up and running, this will do:
docker volume create artifactory-data
docker pull releases-docker.jfrog.io/jfrog/artifactory-jcr:latest
docker run -d --name artifactory -p 8082:8082 -p 8081:8081 -v artifactory-data:/var/opt/jfrog/artifactory releases-docker.jfrog.io/jfrog/artifactory-jcr:latest
You will then access it at localhost:8082 (or localhost:8081, which will just redirect to 8082).
On Ubuntu 18.04, I'm trying to install Hyperledger Cello, and during the install, I get:
make[2]: Entering directory '/home/julien/cello'
docker-compose -f bootup/docker-compose-files/docker-compose-nfs.yml up -d --no-recreate
WARNING: Found orphan containers (cello-user-dashboard, cello-operator-dashboard, cello-watchdog, cello-keycloak-server, cello-parse-server, cello-dashboard_rabbitmq, cello-mongo, cello-keycloak-mysql, cello-engine) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up.
Starting cello-nfs ... error
ERROR: for cello-nfs Cannot start service nfs: driver failed programming external connectivity on endpoint cello-nfs (d1be7a4999731983a12df9f1fb6484c7adf669be7edf01c6d962856ed8a6846f): Error starting userland proxy: listen tcp 0.0.0.0:2049: bind: address already in use
ERROR: for nfs Cannot start service nfs: driver failed programming external connectivity on endpoint cello-nfs (d1be7a4999731983a12df9f1fb6484c7adf669be7edf01c6d962856ed8a6846f): Error starting userland proxy: listen tcp 0.0.0.0:2049: bind: address already in use
ERROR: Encountered errors while bringing up the project.
When trying to figure out which application is using 2049 port, I do:
➜ cello git:(master) ✗ sudo netstat -pna | grep 2049
tcp 0 0 0.0.0.0:2049 0.0.0.0:* LISTEN -
tcp6 0 0 :::2049 :::* LISTEN -
udp 0 0 0.0.0.0:2049 0.0.0.0:* -
udp6 0 0 :::2049 :::* -
unix 3 [ ] STREAM CONNECTED 204951 18122/brave --type=
unix 3 [ ] STREAM CONNECTED 204950 5193/brave
But I get no app name.
I also tried to remove containers with
docker rm -f $(docker ps -aq)
like said in this post, but it didn't work.
How should I do to free this port ?
You can try :
docker stop $(docker ps -a -q)
docker ps # again to make sure containers is off
sudo lsof -i tcp:2049 # now you get and list of process running and using 2049 port find and copy PID
sudo kill -9 yout_PID
Now that the 2049 port is killed, then try start containers again...
It looks as if you have an NFS server running on your host. When you run netstat -p ... as root and you don't see a PID for a port, like this...
tcp 0 0 0.0.0.0:2049 0.0.0.0:* LISTEN -
tcp6 0 0 :::2049 :::* LISTEN -
udp 0 0 0.0.0.0:2049 0.0.0.0:* -
udp6 0 0 :::2049 :::* -
...it generally means there is a kernel service bound to that port. Disabling the kernel NFS server (assuming that you're not using it) should allow you to run your container.
Trying to use jupyter-notebook on a docker image (https://hub.docker.com/r/tensorflow/tensorflow), but having problem where using the port-forwarded address in browser just hangs with the (chrome) home page stuck saying Waiting for 127.0.0... until it just times out.
The docker command being run looks like
➜ ~ docker run -it -p 8888:8888 --rm tensorflow/tensorflow:latest-devel-gpu-py3 jupyter-notebook --ip 0.0.0.0 --no-browser --allow-root
[I 04:26:44.023 NotebookApp] Writing notebook server cookie secret to /root/.local/share/jupyter/runtime/notebook_cookie_secret
[I 04:26:44.042 NotebookApp] Serving notebooks from local directory: /root
[I 04:26:44.043 NotebookApp] The Jupyter Notebook is running at:
[I 04:26:44.043 NotebookApp] http://(f1afd4b163fd or 127.0.0.1):8888/?token=5a838cefbd58822ce3de5a9ab00ed724bc6f9e048017125a
[I 04:26:44.043 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 04:26:44.043 NotebookApp]
Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
http://(f1afd4b163fd or 127.0.0.1):8888/?token=5a838cefbd58822ce3de5a9ab00ed724bc6f9e048017125a
(note, have also tried docker run -it -p 8888:8888 --rm tensorflow/tensorflow:latest-devel-gpu-py3 /run_jupyter.sh --allow-root to similar hanging results).
Checking docker ps shows
➜ ~ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2114609d6d9d tensorflow/tensorflow:latest-devel-gpu-py3 "jupyter-notebook --…" About a minute ago Up About a minute 6006/tcp, 0.0.0.0:8888->8888/tcp mystifying_liskov
Checking for a response via curl shows
➜ ~ curl -v http://127.0.0.1:8888/?token=5a838cefbd58822ce3de5a9ab00ed724bc6f9e048017125a
* Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 8888 (#0)
> GET /?token=5a838cefbd58822ce3de5a9ab00ed724bc6f9e048017125a HTTP/1.1
> Host: 127.0.0.1:8888
> User-Agent: curl/7.47.0
> Accept: */*
>
<at this point just hangs until I ctl+C out>
* Recv failure: Connection reset by peer
* Closing connection 0
curl: (56) Recv failure: Connection reset by peer
and examine the ports shows
➜ ~ sudo netstat -plnt
[sudo] password for me:
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1512/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 2485/cupsd
tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN 2284/smbd
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 1502/mysqld
tcp 0 0 0.0.0.0:139 0.0.0.0:* LISTEN 2284/smbd
tcp 0 0 127.0.0.1:5037 0.0.0.0:* LISTEN 8558/adb
tcp 0 0 127.0.0.1:6000 0.0.0.0:* LISTEN 1006/unicorn.rb --h
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 1954/monitorix-http
tcp6 0 0 :::22 :::* LISTEN 1512/sshd
tcp6 0 0 ::1:631 :::* LISTEN 2485/cupsd
tcp6 0 0 :::445 :::* LISTEN 2284/smbd
tcp6 0 0 :::8888 :::* LISTEN 32491/docker-proxy
tcp6 0 0 :::139 :::* LISTEN 2284/smbd
tcp6 0 0 :::80 :::* LISTEN 1846/apache2
Other post I've seen seem to be people simply not forwarding the port that jupyter expects to use, but that does not seem to be the problem here. This occurs regardless of what docker image is used (so not just that particular image). If anyone has any ideas of what it could be or any debugging advice it would be appreciated.
Resolved the problem.
Restarted the host machine (note, this was the first time restarting since installing docker, but still did not work until...)
Ran sudo /etc/init.d/docker restart (Did this purely based on a hunch when skimming the troubleshooting docs here: https://docs.docker.com/toolbox/faqs/troubleshoot/#configure-http-proxy-settings-on-docker-machines).
Then the docker run ... statement from the posted question worked and can now reach the forwarded port on host machine and can curl the address. An Ubuntu notification popped up saying "Wired connection established".
This is a bit of a lame answer, but it's what worked for me. Oddly, seems have to rerun the sudo /etc/init.d/docker restart statement sometimes to get docker containers to open. Will try to figure out a bit more about what exactly was going on here, but if anyone with more experience thinks they know what may have been happening, please do let us know.
I have started a docker container using the command
sudo docker run -it -P -d plcdimage
The image is built using a Dockerfile which has instruction EXPOSE 8080. Container runs a jboss server with an application deployed on it. Port mappings are :
Command: sudo docker port be1837e849dc
Output: 8080/tcp -> 0.0.0.0:32771
When I try to access the web application running on jboss in the container from the mapped host port using url:
http://IPAddressOfHost:32771/
I get connection refused error. Following is the result of command "netstat -tulpn"
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp6 0 0 :::9999 :::* LISTEN -
tcp6 0 0 :::22 :::* LISTEN -
tcp6 0 0 :::32771 :::* LISTEN -
udp 0 0 0.0.0.0:68 0.0.0.0:* -
I tried doing telnet hostip 32771 and it also results in connection refused.
Docker version 1.12.1
build 23cf638
What could be the possible reason for this?
Thanks in advance
I found that jboss server running inside the container was not listening on 0.0.0.0. One option to do this is, while starting the standalone server use -b 0.0.0.0.
/bin/standalone.sh -b 0.0.0.0