Linux Labs

Containers: Docker and compose / Stage 2 of 11

Ports, variables and restart

Not running Starting usually ~20 s
Leave the lesson

Step 8 of 8 · summary · 2 min

Summary

  • A port inside a container belongs to the container's own network; it appears on the server after publishing with -p server_port:container_port.
  • -e NAME=value sets a container's environment at creation; docker exec … env and docker inspect --format show what the process got.
  • The port and the environment change only by re-creating the container, and the restart policy also with docker update --restart.
  • --restart decides whether a container comes back after a process crash and after a docker service restart; unless-stopped remembers a manual docker stop.
  • curl to port 8080 was refused because nginx listened on port 80 inside site, and no port was published on the server.
Ubuntu 24.04
Loading…