Docker Enterprise has its own image registry (MSR) so that you can store and manage the images that you deploy to your cluster. In this topic, you push an image to MSR and later deploy it to your cluster, using the Kubernetes orchestrator.
Instead of building an image from scratch, we’ll pull the official WordPress image from Docker Hub, tag it, and push it to MSR. Once that WordPress version is in MSR, only authorized users can change it.
To push images to MSR, you need CLI access to a licensed installation of Docker Enterprise.
When you’re set up for CLI-based access to a licensed Docker Enterprise instance, you can push images to MSR.
Pull the public WordPress image from Docker Hub:
docker pull wordpress
Tag the image, using the IP address or DNS name of your MSR instance:
docker tag wordpress:latest <msr-url>:<port>/admin/wordpress:latest
Log in to a Docker Enterprise manager node.
Push the tagged image to MSR:
docker image push <msr-url>:<port>/admin/wordpress:latest
In the MSR web UI, confirm that the wordpress:latest
image is store
in your MSR instance.
latest
tag is present.You’re ready to deploy the wordpress:latest
image into production.
With the WordPress image stored in MSR, Docker Enterprise can deploy the image to a Kubernetes cluster with a simple Deployment object:
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: wordpress-deployment
spec:
selector:
matchLabels:
app: wordpress
replicas: 2
template:
metadata:
labels:
app: wordpress
spec:
containers:
- name: wordpress
image: <msr-url>:<port>/admin/wordpress:latest
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: wordpress-service
labels:
app: wordpress
spec:
type: NodePort
ports:
- port: 80
nodePort: 30081
selector:
app: wordpress
The Deployment object’s YAML specifies your MSR image in the pod
template spec: image: <msr-url>:<port>/admin/wordpress:latest
. Also,
the YAML file defines a NodePort
service that exposes the WordPress
application, so it’s accessible from outside the cluster.