Error response from daemon: ports are not available: exposing port tcp 0.0.0.0:3306 -> 0.0.0.0:0: listen tcp 0.0.0.0:3306: bind: address already in use
I’m sure we’ve encountered this error plenty of times, the one that looks like this. Show ERROR: for postgres Cannot start service postgres: driver failed programming external connectivity on endpoint test_postgres_1 Bind for 0.0.0.0:5432 failed: port is already allocated In this example, we have another container or an application listening on the port 5432 on our machine. This prevents our service from allocating that port. Now, how can we fix this? I was using docker-compose to start and stop my applications, so naturally, I used docker-compose ps to list all running containers and docker-compose down to stop those containers. However, docker-compose commands only execute on containers related to images in our docker-compose.yml files. We also need to check containers started without docker-compose. This is the process I would use to stop the correct containers. First, I would stop all containers started by docker-compose (or just that one container). Then, I would list all running containers. CONTAINER ID IMAGE ... PORTS NAMES 45eec0e12d63 postgres ... 0.0.0.0:5432->5432/tcp test_postgres_1 Let’s grab the CONTAINER ID and stop/remove the container. docker stop 45eec0e12d63 docker rm 45eec0e12d63
Applies to: This article talks about common errors seen when deploying and using SQL Server Docker containers, and provide troubleshooting techniques to help resolve the issue. Docker command errorsIf you get errors for any docker commands, make sure that the docker service is running, and try to run with elevated permissions. For example, on Linux, you might get the following error when running docker commands: Cannot connect to the Docker daemon. Is the docker daemon running on this host?If you get this error on Linux, try running the same commands prefaced with sudo. If that fails, verify the docker service is running, and start it if necessary. sudo systemctl status docker sudo systemctl start dockerOn Windows, verify that you're launching PowerShell or your command-prompt as an Administrator. SQL Server container startup errorsIf the SQL Server container fails to run, try the following tests:
Enable dump capturesIf the SQL Server process is failing inside the container, you should create a new container with SYS_PTRACE enabled. This adds the Linux capability to trace a process, which is necessary for creating a dump file on an exception. The dump file can be used by support to help troubleshoot the problem. The following docker run command enables this capability.
docker run -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=
docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=
docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=
docker run -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=
docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=
docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD= SQL Server connection failuresIf you can't connect to the SQL Server instance running in your container, try the following tests:
SQL Server Availability GroupsIf you're using Docker with SQL Server Availability Groups, there are two additional requirements.
SQL Server setup and error logsYou can look at the SQL Server setup and error logs in /var/opt/mssql/log. If the container isn't running, first start the container. Then use an interactive command-prompt to inspect the logs. You can get the container ID by running the command docker ps. docker startFrom the bash session inside your container, run the following commands: cd /var/opt/mssql/log cat setup*.log cat errorlog
Tip If you mounted a host directory to /var/opt/mssql when you created your container, you can instead look in the log subdirectory on the mapped path on the host. Execute commands in a containerIf you have a running container, you can execute commands within the container from a host terminal. To get the container ID run: docker ps -aTo start a bash terminal in the container run: docker exec -itNow you can run commands as though you're running them at the terminal inside the container. When finished, type exit. This exits in the interactive command session, but your container continues to run. Next steps
|