When I run ddev start, I get the following error in the command line:
Failed to start amdocs-stage: Unable to listen on required ports, port 443 is already in use,
Troubleshooting suggestions at https://ddev.readthedocs.io/en/stable/users/troubleshooting/#unable-listen
I went to my configuration file, replaced port 443 for 8443, and port 80 for 8000. However after I run ddev restart, I still see the same error. All instructed here
I don't have lando, and stopped all the services running through brew.
My Docker desktop is running, and the config.yaml inside .ddev looks like this:
name: cohesion-test
type: drupal8
docroot: web
php_version: "7.4"
webserver_type: nginx-fpm
router_http_port: "8000"
router_https_port: "8443"
xdebug_enabled: false
additional_hostnames: []
additional_fqdns: []
mariadb_version: "10.3"
mysql_version: ""
use_dns_when_possible: true
composer_version: ""
web_environment: []
How can I fix this?
You probably have more than one project active (or perhaps "paused") and the other projects still use port 443 (router_https_port is not a global setting). Do a ddev poweroff to stop all projects and then ddev start. If that doesn't do it, remove any additional containers that ddev may not know about with docker rm -f $(docker ps -aq).
You also may want to look at https://github.com/drud/ddev/issues/2981, which explains that there is a bug in current Docker Desktop for Mac v3.3.3, which regularly creates problems with port access that require ddev poweroff and a docker restart.
Related
Instead of using ddev share, I want to run ddev applications on a virtual server (Hetzner, Ubuntu installed, pre-installed docker ce).
As docker already reserved port 80:
Is there a way to forward a specific ddev port to the same port listening to docker?
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1650/docker-proxy
My ddev test application is configured to port 8080 and is accessible.
The ddev configuration:
router_http_port: "80"
router_https_port: "443"
host_webserver_port: "8080"
If I change to
router_http_port: "80"
router_https_port: "443"
host_webserver_port: "80"
I'm (of course) running into
Failed to start test: Unable to listen on required ports, port 80 is already in use
Can this conflict be solved by forwarding a port (ddev router) or do I need to change the docker port?
Docker itself does not use ports 80 or 443, so you have something else running there (the most common offender is going to be apache). The docs at https://ddev.readthedocs.io/en/latest/users/troubleshooting/#webserver-ports-are-already-occupied-by-another-webserver explain how to debug this. Since it says docker-proxy is running there, it probably means that you have a docker container already running and bound to port 80.
Try these things:
ddev poweroff (to make sure all ddev things are stopped)
docker ps -a will show you other containers that may be running
docker rm -f $(docker ps -aq) will stop all running containers.
I think when you do these things you'll find docker not listening any more; now you just have to find out why it was listening.
As you already know, the docs for various kinds of sharing are at https://ddev.readthedocs.io/en/latest/users/topics/sharing/ and you may also be interested in the general on-server approaches in https://ddev.readthedocs.io/en/latest/users/alternate-uses/#casual-project-webhosting-on-the-internet-including-lets-encrypt
I have a spring-config-sever project that I am trying to run via Docker. I can run it from the command line and my other services and browser successfully connect via:
http://localhost:8980/aservice/dev
However, if I run it via Docker, the call fails.
My config-server has a Dockerfile:
FROM openjdk:8-jdk-alpine
VOLUME /tmp
ARG JAR_FILE=build/libs/my-config-server-0.1.0.jar
ADD ${JAR_FILE} my-config-server-0.1.0.jar
EXPOSE 8980
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/my-config-server-0.1.0.jar"]
I build via:
docker build -t my-config-server .
I am running it via:
docker run my-config-server -p 8980:8980
And then I confirm it is running via
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1cecafdf99fe my-config-server "java -Djava.securit…" 14 seconds ago Up 13 seconds 8980/tcp suspicious_brahmagupta
When I run it via Docker, the browse fails with a "ERR_CONNECTION_REFUSED" and my calling services fails with:
Could not locate PropertySource: I/O error on GET request for
"http://localhost:8980/aservice/dev": Connection refused (Connection
refused);
Adding full answer based on comments.
First, you have to specify -p before image name.
docker run -p 8980:8980 my-config-server.
Second, just configuring localhost with host port won't make your my-service container to talk to other container. locahost in container is within itself(not host). You will need to use appropriate docker networking model so both containers can talk to each other.
If you are on Linux, the default is Bridge so you can configure my-config-server container ip docker inspect {containerIp-of-config-server} as your config server endpoint.
Example if your my-config-server ip is 172.17.0.2 then endpoint is - http://172.17.0.2:8980/
spring:
cloud:
config:
uri: http://172.17.0.2:8980
Just follow the docker documentation for little bit more understanding on how networking works.
https://docs.docker.com/network/network-tutorial-standalone/
https://docs.docker.com/v17.09/engine/userguide/networking/
If you want to spin up both containers using docker-compose, then you can link both containers using service name. Just follow Networking in Compose.
I could imagine that the application only listens on localhost, ie 127.0.0.1.
You might want to try setting the property server.address to 0.0.0.0.
Then port 8980 should also be available externally.
I want to set up redis configuration in docker.
I have my own redis.conf under D:/redis/redis.conf and have configured it to have bind 127.0.0.1 and have uncommented requirepass foobared
Then used this command to load this configuration in docker:
docker run --volume D:/redis/redis.conf:/usr/local/etc/redis/redis.conf --name myredis redis redis-server /usr/local/etc/redis/redis.conf
Next,
I have docker-compose.yml in my application in maven Project under src/resources.
I have the following in my docker-compase.yml
redis:
image: redis
ports:
- "6379:6379"
And i execute the command :
docker-compose up
The Server runs, but when i check with the command:
docker ps -a
it Shows that redis Image runs at 0.0.0.0:6379.
I want it to run at 127.0.0.1.
How do i get that?
isn't my configuration file loading or is it wrong? or my commands are wrong?
Any suggestions are of great help.
PS: I am using Windows.
Thanks
Try to execute:
docker inspect <container_id>
And use "NetworkSettings"->"Gateway" (it must be 172.17.0.1) value instead of 127.0.0.1.
You can't use 127.0.0.1 as your Redis was run in the isolated environment.
Or you can link your containers.
So first of all you should not be worried about redis saying listening on 0.0.0.0:6379. Because redis is running inside the container. And if it doesn't listen on 0.0.0.0 then you won't be able to make any connections.
Next if you want redis to only listen on localhost on localhost then you need to use below
redis:
image: redis
ports:
- "127.0.0.1:6379:6379"
PS: I have not run container or docker for windows with 127.0.0.1 port mapping, so you will have to see if it works. Because host networking in Windows, Mac and Linux are different and may not work this way
In my current job we have development environment made with docker-compose.
One container is nginx, which provide routing to other containers.
Everything seems fine and work to my colleague on windows and osx. But on my system (osx El Capitan), there is problem with accessing nginx container on port 80.
There is setup of container from docker-compose.yml
nginx:
build: ./dockerbuild/nginx
ports:
- 80:80
links:
- php
volumes_from:
- app
... and more
In ./dockerbuild/nginx there is nothing special, just nginx config as we know it from everywhere.
When I run everyting with docker-compose create and docker-compose start. Then docker ps give me
3b296c1e4775 docker_nginx "nginx -g 'daemon off" About an hour ago Up 47 minutes 0.0.0.0:80->80/tcp, 443/tcp docker_nginx_1
But when I try to access it for example via curl I get error. curl: (7) Failed to connect to localhost port 80: Connection refused
I try to run container with port 81 and everything works fine.
Port is really binded to docker
22:47 $ sudo lsof -i -n -P | grep TCP
...
com.docke 14718 schovi 38u IPv4 0x6e9c93c51ec4b617 0t0 TCP *:80 (LISTEN)
...
Firewall in osx is turned off and I have no other security.
if you are using docker-for-mac:
Accessing by localhost:80 is correct, though you still have to ensure you do not have a local apache/nginx service running. Often leftovers from boxen/homebrew exist binding that port, because thats what developers did back then :)
if you are using dockertoolbox/virtualbox/whatever hypervisor
You will not be able to access it by localhost, by by the docker-machine ip, so write docker-machine ip default and the use http://$ip:80 in your browser
if that does not help
Ensure your nginx container actually does work, so connect to the container: docker exec -i -t <containerid> bash
and then run ps aux nginx or if telnet is installed try to connect to localhost
Solved!
Problem was, that long long time ago I installed pow (super simple automated rails server which run application on app_name.local domain). And this beast left LaunchAgent script which update pf to forward port 80 to pow port.
In my current job we have development environment made with docker-compose.
A privilege to use.
[W]hen I try to access [nginx on port 80] for example via curl I get error.
Given there's nothing from causing you from accessing docker on your host os you should look at the app running inside the container to ensure it's binding to the correct host, e.g. 0.0.0.0 and not localhost.
For example, if you're running Nuxt inside a container with nuxt-ts observe Nuxt will default to localhost thereby causing the container not to connect to the docker network whereas npx nuxt-ts -H 0.0.0.0 gets things squared away with the container's internal server connecting to the ip of the docker network used (verify ip like docker container inspect d8af01990363).
I would like any computer on the same network as my Mac to be able to access the dockerized Rails web app running on my Mac.
On my Mac (10.9.5) my Rails 4.2.4 web app is running fine in Docker when I access it via the docker ip and the port I assigned, 192.168.99.100:3000
Docker 1.8.1 is running under Virtualbox 5.0.2.
I'm using Docker-compose and the relevant part of the docker-compose.yml file is:
web:
build: .
command: 'bash -c ''bundle exec unicorn -p $PORT -c ./config/unicorn-local.rb'''
working_dir: /app/user
env_file:
- .docker_dev_env_config
- .docker_dev_env_personal
environment:
PORT: 3000
DATABASE_URL: 'postgres://postgres:#herokuPostgresql:5432/postgres'
ports:
- '3000:3000'
links:
- herokuPostgresql
and my Dockerfile is
FROM heroku-ruby2.0.0 # a local image based on heroku/ruby with ruby 2.0.0
EXPOSE 3000
ENV widget foo
My Mac's ip address on the local network is always set to 192.168.0.33.
How do I permit testers on the local network to access the running dockerized app via 192.168.0.33:3000 ?
(FWIW if I run my web app under Vagrant - instead of Docker - other testers on the network can access the web app by browsing 192.168.0.33:3000. My Vagrant is also running under Virtualbox. My Vagrantfile contains config.vm.network :forwarded_port, guest: 3000, host: 3000 but I do not see any equivalent for docker-compose.yml)
You need to port forward the port 3000 from the VM to your localhost. For this you can run the following script
VBoxManage modifyvm "boot2docker-vm" --natpf1 "tcp-port$3000,tcp,,$3000,,$3000";
VBoxManage modifyvm "boot2docker-vm" --natpf1 "udp-port$3000,udp,,$3000,,$3000";
This will port forward to your localhost. In case you want to port forward to some other interface, you have to provide that interface's IP address in the command. This is the general syntax for the --natpf command
[--natpf<1-N> [<rulename>],tcp|udp,[<hostip>],<hostport>,[<guestip>],<guestport>]
So you can modify it accordingly.
Refer to this for further reading. Docker on Mac. The Missing Guide
The 'default' Virtualbox created when using docker-toolkit's Docker Quickstart Terminal app does not have any port other than an ssh defined.
The solution on the Mac, when using VirtualBox with Docker is:
Run VirtualBox
click the 'default' box (or whichever box your Docker setup uses)
go to 'Settings > Network > Adapter 1
click 'Port Forwarding'
create a new rule the example below fwds 3000 to 3000
(be sure to leave the host ip column blank)