commonly used image hosting technology
1.self-built(registry,harbor,etc)
2.hosting platform(tencent cloud,aliyun etc)
address of ali cloud container image service:
https://cr.console.aliyun.com
praparatory work
1.coding go project
package main
import "fmt"
func main() {
fmt.Println("helloworld")
}
go run main.go
2.pacakge the project
GOOS=linux GOARCH=amd64 go build main.go
3.upload files to the server and run the project in the background....
4.coding Dockerfile and package helloworld project
#under the project level directory,create a new Dockerfile
FROM alpine:latest
COPY main /app/main
#ENTRYPOINT ["/user-srv"]
CMD ["/app/main"]
5.generate docker images
#docker images helloo , . is the dockerfile directory location
docker build -t hello:v1 .
6.run the helloo container
docker run hello:v1
give the image a label
docker tag hello:v1 registry.cn-hangzhou.aliyuncs.com/gosrc/godemo:v1
view mirror
docker images
Log in to Aliyun Docker Registry
docker login --username=hi313*****@aliyun.com registry.cn-hangzhou.aliyuncs.com
push the image to registry
docker push registry.cn-hangzhou.aliyuncs.com/gosrc/godemo:v1
3.deploy docker images to the target server
log in to Ali Cloud docker server at the target server terminal
docker login --username=hi313*****@aliyun.com registry.cn-hangzhou.aliyuncs.com
pull the image to the local server on the target server
docker pull registry.cn-hangzhou.aliyuncs.com/gosrc/godemo:v1
run the docker container
docker run registry.cn-hangzhou.aliyuncs.com/gosrc/godemo:v1
docker ps -a