Build, Push, and Pull an Image with
After you have loaded the vSphere Integrated Containers Registry certificate into a
dch-photon container VM, test the
dch-photon Docker container host by building an image and pushing it to vSphere Integrated Containers Registry. Then, pull them image into a VCH to deploy it.
- You performed one of the procedures in either Add the Registry Certificate to a Custom Image or Manually Add the Registry Certificate to a
dch-photonVM to create an instance of the
dch-photoncontainer VM that includes the CA certificate of your vSphere Integrated Containers instance.
- For simplicity, this example uses a virtual container host (VCH) that was deployed with the
--no-tlsverifyoption. If your VCH implements TLS verification of clients, you must import the VCH certificates into your Docker client and adapt the Docker commands accordingly. For information about how to connect a Docker client to a VCH that uses full TLS authentication, see Connecting to the VCH in Configure the Docker Client for Use with vSphere Integrated Containers.
docker infoto test that the Docker container host running in the
dch-photoncontainer VM has started correctly.
By specifying port 12375 you direct the Docker client to the Docker container host that is running in the VCH.
docker -H vch_address:12375 info
Test that you can authenticate with the registry.
You should not need to log in if your client is already authenticated with the registry, but the
logincommand is included here for clarity.
docker -H vch_address:12375 login registry_address
Test that you can pull images from the registry.
docker -H vch_address:12375 pull registry_address/default-project/dch-photon:1.13
Remove the test image that you just pulled.
docker rmi registry_address/default-project/dch-photon:1.13
Create a simple
Dockerfileand save it in the current directory.
FROM debian:latest RUN apt-get update -y && apt-get install -y fortune-mod fortunes ENTRYPOINT ["/usr/games/fortune", "-s"]
Build an image from the
dch-photonDocker container host, and tag it with the path to a project in vSphere Integrated Containers Registry.
docker -H vch_address:12375 build -t registry_address/default-project/test-container .
Push the image from the
dch-photonDocker container host to the registry.
docker -H vch_address:12375 push registry_address/default-project/test-container
Pull the image from the registry into the VCH.
docker -H vch_address:2376 --tls pull registry_address/default-project/test-container
Run a container from this image on the VCH.
docker -H vch_address:2376 --tls run registry_address/default-project/test-container
List the containers that are running and stopped in the VCH.
docker -H vch_address:2376 --tls ps -a
The container that you ran from an image that you built and pushed to vSphere Integrated Containers Registry in
dch-photon appears in the list of containers that have been run in this VCH.
dch-photon container VM that you run creates an anonymous volume in the
default volume store. This anonymous volume is not deleted when you delete a
dch-photon container VM. When you delete
dch-photon container VMs, you must manually remove the anonymous volume from the volume store.