Introduction
Docker allows you to deploy applications quickly by reducing the risk of failure when deploying in multiple environments such as: development, staging and production.
Goals
- We will ceate simple Golang Hello World Application
- We will create Docker Image Golang-Hello-World
- We will run Docker Container from Golang-Hello-World
- Lastly we will access our application in the browser
Prerequisites
For this tutorial you will need to install
- Install docker in your machine
- https://docs.docker.com/engine/install/
Create Golang Hello World Application
Create a folder GOHELLO-WORLD > main.go
Our application listen in port 8080
In folder GOHELLO-WORLD you should create Dockerfile and then type the syntax
We will create a Docker Image with name gohello-world, go to terminal to folder gohello-world and then type:
$ docker build -t gohello-world .
As you can see we already created the Docker Image
$ docker images
Now we will create a Container from our Image
$ docker container create --name gohello-world-container -p 8181:8080 gohello-world
$ docker container start gohello-world-container
8181(is Host Port):8080(is Container Port)
We also to make sure our container already running by type:
$ docker container ls
you can see the STATUS (is Up 3 minutes) with port 8181
Access in your browser:
http://localhost:8181
And boom our app already running with docker container ☺
Hope you guys like it, Thank you 😊







Tidak ada komentar:
Posting Komentar