Docker
Open your favorite Terminal and run these commands. Installing docker on Mac with Homebrew Cask:
brew install docker --caskGet docker version:
docker --versionIf the above command doesn’t return the Docker version, you may need to start the Docker daemon first. You can do that by searching for Docker in Spotlight or in the Application folder in Finder and running it. Get docker info:
docker infoCreate a docker image: Before creating a docker image, make sure to add a Dockerfile in the current directory
docker build -t golang-docker .Run a docker image:
docker run -d -p 80:80 golang-dockerList all images docker images:
docker imagesCheck the running processes:
docker psStop a running process:
docker stop 35a3173485aaLogin in docker hub:
docker loginTag an image to make it ready for pushing to docker hub:
docker tag golang-docker mnkrana/golang-docker:latestPush tagged image to docker hub:
docker push mnkrana/golang-dockerLogin in github docker packages: First, export your personal access token from developer setting in github. Then, export it like this
export PAT=<your PAT>Now, to login
echo $PAT | docker login ghcr.io --username phanatic --password-stdinPush to github packages: Make sure to tag your image with ghcr.io like this
docker tag golang-docker ghcr.io/mnkrana/golang-dockerNow, push it to github packages:
docker push ghcr.io/mnkrana/golang-docker2:latestRemove docker image:
docker image rm -f mnkrana/golang-dockerShow all containers:
docker ps -aDelete all containers:
docker rm -f $(docker ps -a -q)Prune docker system:
docker system prune -aCheck logs
docker run --name test -d -p 80:80 golang-docker
docker logs -f testInspect running container
docker inspect <container-name>