01_Create_Docker-IMG

command
v0.0.0-...-c492333 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 7, 2024 License: MIT Imports: 4 Imported by: 0

README

Building a basic Go docker file

  • Create a newfolder and cd into it
  • Create a main.go and Dockerfile
  • Insert your golang logic in main.go
  • Edit the docker file and insert the following (explanation of code is in the Dockerfile)
FROM golang:1.12.0-alpine3.9
RUN mkdir /app
ADD . /app
WORKDIR /app
RUN go build -o main .
CMD ["/app/main"]

  • Use the following command to build an image. (Can change golang-hi-server of your choice)
docker build -t golang-hi-server .
  • Check if image is made
docker images
  • Run the docker image created using (golang-hi-server is the name of img)
docker run -d -p 8080:8082 -it golang-hi-server
  • open http://localhost/8080 to see the project in action

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL