the image runs successfully.But i can not get the response.
here is the run command.The boot-1.0-SNAPSHOT.jar is just a simple SpringBoot project.
docker run -d -p 8888:8888 -v /usr/makoto/boot-1.0-SNAPSHOT.jar:/usr/makoto/boot-1.0-SNAPSHOT.jar --name makoto java:8u111 java -jar /usr/makoto/boot-1.0-SNAPSHOT.jar
here is the curl command
curl -GET 127.0.0.1:8888/ttt
The problem has been solved.When use Centos in the vmware,docker runs successfully.
Anyway,I am grateful for your help.The reason caused this problem is still unknown.Welcome you write down your conjecture.I will test it one by one.
It's simply because you are trying to curl IP 0.0.0.0:8888, You should curl localhost:8888 instead
curl -GET localhost:8888/ttt
if you want to call a container from the host you can use the localhost, 127.0.0.1 with the exposed port for the container.
Related
I've been using for years a containerized version of a web-application on my development laptop. Usually I do something like
docker run -it -d --rm -h app.localhost my-app
and, having added app.localhost to my hosts file, going to http://app.localhost everything works. Yesterday an update came for docker and I'm no longer able to do that. Running the image with the same command line options and trying to connect to the application I get a browser error page and checking the logs in the container shows no request at all got to the web server. Running curl http://app.localhost in a terminal works fine, and I've been able to fix the problem changing the my command line options to
docker run -it -d --rm -p 80:80 -h app.localhost my-app
i.e. explicitly exposing port 80.
Can anyone explain what went wrong? And why would curl and my web browser behave differently?
Edit: to clarify: I'm referring to an update of the docker packages for my OS (Ubuntu 18 if that matters).
I have recently heard about sitespeed.io and started using it to measure performance of my site.
I am running it in a docker container on my gcp cloud instance.
The problem is everytime i run the command it stores the result in a particular directory sitespeed-result and then I need to copy the whole thing on my local windows machine to view index.html file.
Is it possible to run this on a server like apache? I mean for example I can run an apache container on my docker host but how do i map this sitespeed io result so that it can be available using http://my-gcp-instance:80 where my apache container is running on port 80.
sudo docker run -v "$(pwd)":/sitespeed.io sitespeedio/sitespeed.io:13.3.0 https://mywebsite.com
Sorry for posting thr question this but I got it working.
sudo docker run -dit --name my-apache -p 8080:80 -v "$(pwd)":/usr/local/apache2/htdocs/ httpd:2.4
(pwd) is where i am storing the sitespeed results.
This is my Dockerfile:
FROM sonatype/nexus3:latest
COPY ./scripts/ /bin/scripts/
RUN curl -u admin:admin123 -X GET 'http://localhost:8081/service/rest/v1/repositories'
After running build:
docker build -t test./
The input is:
(7) Failed connect to localhost:8081; Connection refused
Why? Sending requests to localhost (container which is building) is possible only after run it? Or maybe I should add something to Dockerfile?
Thanks for help :)
Why do you want to connect to the service while it is build?
By default the service is not running yet, you'll need to start the container first.
Remove the curl and start the container first
docker run test
Dockerfile is a way to create images, then you create containers from images. Ports are up to serve once the container is up & running. Hence, you can't do a curl while building an image.
Change Dockerfile to -
FROM sonatype/nexus3:latest
COPY ./scripts/ /bin/scripts/
Build image -
docker build -t test .
Create container from the image -
docker run -d --name nexus -p 8081:8081 test
Now see if your container is running & do a curl -
docker ps
curl -u admin:admin123 -X GET 'http://localhost:8081/service/rest/v1/repositories'
I trying to startup a neo4j container for test data and use a separate bolt port.
docker run --env=NEO4J_AUTH=none
--env=NEO4J_dbms_security_procedures_unrestricted=apoc.\\\*
--publish=7475:7474 --publish=7688:7687
--volume=$HOME/neo4j/conf-test:/conf
--volume=$HOME/neo4j/test-data:/data
--volume=$HOME/neo4j/plugins:/plugins
--name=neo4j-test neo4j
In $HOME/neo4j/conf-test/neo4j.conf file I have tried:
dbms.connector.bolt.listen_address=:7688 # doesn't do anything
dbms.connector.bolt=:7688 # error also error with =7688
dbms.connector.bolt.address=0.0.0.0:7688 # does nothing
When I open my browser to http://localhost:7475/browser/ it tries to connect to 7687
I use :server connect command to connect but it doesn't save the setting; though it connects fine. Everytime I refresh I have to enter them again.
Any thoughts?
I couldn't get this working with a config file since the docker container kept overwriting the file with its own settings.
Trick for me was to note that the listen_address and advertised_address variables require a double underscore:-
docker run \
-e NEO4J_dbms_connector_bolt_listen__address=:7688 \
-e NEO4J_dbms_connector_bolt_advertised__address=:7688 \
--rm \
--name neo4j \
--publish=7575:7474 \
--publish=7688:7687 \
neo4j
2018-02-07 11:33:34.593+0000 INFO Bolt enabled on 0.0.0.0:7688.
This got me running on the correct port!
Got it.
So I was missing advertised_address.
Leaving my docker run command alone,
I just add the following lines (or modify) to my $HOME/neo4j/conf-test/neo4j.conf file
dbms.connector.bolt.listen_address=:7688
dbms.connector.bolt.advertised_address=:7688
Works for me.
I'm brand new to both TeamCity and Docker. I'm struggling to get a Docker container with TeamCity running and usable on my local machine. I've tried several things, to no avail:
I installed Docker for Mac per instructions here. I then tried to run the following command, documented here, for setting up teamcity in docker:
docker run -it --name teamcity-server-instance \
-v c:\docker\data:/data/teamcity_server/datadir \
-v c:\docker\logs:/opt/teamcity/logs \
-p 8111:8111 \
jetbrains/teamcity-server
That returned the following error: docker: Error response from daemon: Invalid bind mount spec "c:dockerdata:/data/teamcity_server/datadir": invalid mode: /data/teamcity_server/datadir.
Taking a different tack, I tried to follow the instructions here - I tried running the following command:
docker run -it --name teamcity -p 8111:8111 sjoerdmulder/teamcity
The terminal indicated that it was starting up a web server, but I can't browse to it at localhost, nor at localhost:8111 (error ERR_SOCKET_NOT_CONNECTED without the port, and ERR_CONNECTION_REFUSED with the port).
Since the website with the docker run command says to install Docker via Docker Toolbox, I then installed that at the location they pointed to (here). I then tried the
docker-machine ip default
command they suggested, but it didn't work, error "Host does not exist: "default"". That makes sense, since the website said the "default" vm would be created by running Docker Quickstart and I didn't do that, but they don't provide any link to Docker Quickstart, so I don't know what they are talking about.
To try to get the IP address the container was running on, I tried this command
docker inspect --format='{{.Name}} - {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $(docker ps -aq)
That listed the names of the running containers, each followed by a hyphen, then nothing. I also tried
docker ps -a
That listed running contaners also, but didn't give the IP. Also, the port is blank, and the status says "exited (130) 4 minutes ago", so it doesn't seem like the container stayed alive after starting.
I also tried again with port 80, hoping that would make the site show at localhost:
docker run -it --name teamcity2 -p 80:80 sjoerdmulder/teamcity
So at this point, I'm completely puzzled and blocked - I can't start the server at all following the instructions on hub.docker.com, and I can't figure out how to browse to the site that does start up with the other instructions.
I'll be very grateful for any assistance!
JetBrains now provides official docker images for TeamCity. I would recommend starting with those.
The example command in their TeamCity server image looks like this
docker run -it --name teamcity-server-instance \
-v <path to data directory>:/data/teamcity_server/datadir \
-v <path to logs directory>:/opt/teamcity/logs \
-p <port on host>:8111 \
jetbrains/teamcity-server
That looks a lot like your first attempt. However, c:\docker\data is a Windows file path. You said you're running this on a mac, so that's definitely not going to work.
Once TeamCity starts, it should be available on port 8111. That's what -p 8111:8111 part of the command does. It maps port 8111 on your machine to port 8111 in the VM Docker for Mac creates to run your containers. ERR_CONNECTION_REFUSED could be caused by several things. Two most likely possibilities are
TeamCity could take a little while to start up and maybe you didn't give it enough time. Solution is to wait.
-it would start the TeamCity container in interactive mode. If you exit out of the terminal window where you ran the command, the container will also probably terminate and will be inaccessible. Solution is to not close the window or run the container in detached mode.
There is a good overview of the differences between Docker for Mac and Docker Toolbox here: Docker for Mac vs. Docker Toolbox. You don't need both, and for most cases you'll want to use Docker for Mac for testing stuff out locally.