Dino Geek, try to help you

How to map ports in Docker?


Mapping ports in Docker can be done using the `-p` or `—publish` option when running a docker container from an image.

The syntax for mapping ports is as follows:

```
docker run -p host-port:container-port image-name
```
Here:

- `host-port` is the port number on your machine.
- `container-port` is the port number in the Docker container.
- `image-name` is the name of the Docker image.

For example, if you want to run an application in a Docker container, which listens on port `5000`, and you want to access this application on your machine on port `8080`, you can run:

```
docker run -p 8080:5000 image-name
```

After running this, Docker will start a new container from `image-name`, and any connections made to `localhost` on port `8080` on your machine will be forwarded to port `5000` within the Docker container.

If you want to bind the container’s port to all IP Addresses (`0.0.0.0`), you can specify the IP address before the host port:

```
docker run -p 0.0.0.0:8080:5000 image-name
```


Simply generate articles to optimize your SEO
Simply generate articles to optimize your SEO





DinoGeek offers simple articles on complex technologies

Would you like to be quoted in this article? It's very simple, contact us at dino@eiki.fr

CSS | NodeJS | DNS | DMARC | MAPI | NNTP | htaccess | PHP | HTTPS | Drupal | WEB3 | LLM | Wordpress | TLD | Domain name | IMAP | TCP | NFT | MariaDB | FTP | Zigbee | NMAP | SNMP | SEO | E-Mail | LXC | HTTP | MangoDB | SFTP | RAG | SSH | HTML | ChatGPT API | OSPF | JavaScript | Docker | OpenVZ | ChatGPT | VPS | ZIMBRA | SPF | UDP | Joomla | IPV6 | BGP | Django | Reactjs | DKIM | VMWare | RSYNC | Python | TFTP | Webdav | FAAS | Apache | IPV4 | LDAP | POP3 | SMTP

| Whispers of love (API) | Déclaration d'Amour |






Legal Notice / General Conditions of Use