menu
techminis

A naukri.com initiative

google-web-stories
Home

>

Devops News

>

Day 5: Int...
source image

Dev

3w

read

21

img
dot

Image Credit: Dev

Day 5: Interacting with Containers

  • Today we will continue with our Go application from Day 4 and make it a bit more interesting.
  • We will start by running a simple HTTP server and then see how we can interact with it!
  • Printing hello world is of course a bit boring, so let's make our application a bit more interesting by adding a simple HTTP server.
  • Here we basically just create one route (/) that will print Hello World! when someone visits the root path.
  • You can still use the same Dockerfile from yesterday and build the image just like we did yesterday.
  • This is because Docker containers are isolated from the host by default.
  • You need to explicitly tell Docker that you want to expose a port.
  • The expose instruction actually doesn't expose the port to the host, it is basically just documentation to bridge the knowledge between the developer who wrote the Dockerfile and the people who will use it.
  • I want to show you three helpful commands to interact with your containers. docker ps, docker stats, and docker exec!
  • The -it flags are used to attach your terminal to the container so you can use it.

Read Full Article

like

1 Like

For uninterrupted reading, download the app