I want to deploy a simply docker container to my Kubernetes cluster. I'm on Docker for Mac (Edge mode since that's what supports Kubernetes), and I don't know how to push my image to my Google Cloud Container Registry.
Following the docs, I run:
docker stack deploy --compose-file ./docker-compose.yml my-app
and I get this in return:
Ignoring unsupported options: build
this node is not a swarm manager. Use "docker swarm init" or "docker swarm join" to connect this node to swarm and try again
And here is my docker-compose.yml
:
version: '3'
services:
web:
build: ./
environment:
FLASK_APP: myApp
FLASK_ENV: development
command: flask run --host=0.0.0.0
ports:
- "9090:5000"
volumes:
- ./app:/app
volumes:
data:
driver: local
What am I doing wrong?
To push a Docker image to a remote Docker registry you need to follow the next steps:
docker build .
docker tag <image_name> <repository_name_or_address>/<image_name>
docker login <repository_name_or_address>
commanddocker push <repository_name_or_address>/<image_name>
commandSteps for authorization can differ for various types of repositories. For Google Cloud Container Registry, you need to look through this link. For more information, you can also visit the link on the Docker official site.
After you push the image to the remote Docker registry, you can use it in Kubernetes. The simplest command for that is kubectl run <name_of_your_deployment> --image=<repository_name_or_address>/<image_name>
It is possible that you will need to configure Kubernetes for pulling images from your private repository. In this case, use instructions posted here.