Chan
Chan

Reputation: 1969

Can't access docker container by port mapping

Host: Digital Ocean
OS: Ubuntu 18.04.4 LTS
Docker version: 19.03.12, build 48a66213fe

example 1

docker run -itd --name web -p 9000:80 php:7.2:apache

| 76a6235c907c | php:7.2-apache | "docker-php-entrypoi…" | 5 days ago | Up 5 days | 0.0.0.0:9000->80/tcp | web   |

The container started successfully, but I can't access the service

I got curl: (56) Recv failure: Connection reset by peer, even I turn off the firewall

but it works INSIDE the container

docker exec web curl -sL localhost:80

got

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access this resource.</p>
<hr>
<address>Apache/2.4.38 (Debian) Server at localhost Port 80</address>
</body></html>

example 2

docker run --rm busybox ping www.google.com

got

ping: bad address 'www.google.com'

I think it's about virtual ethernet card, I installed docker via https://get.docker.com/, and already uninstalled entirely and re-install again, still the same

Upvotes: 0

Views: 348

Answers (1)

Damith Udayanga
Damith Udayanga

Reputation: 924

Make sure to open ports on the digital ocean cloud firewall. Also, check the your VPS firewall too.

Upvotes: 0

Related Questions