Deploy a container through the command line
- You can verify connection via
cf ic images
. This will show a list of all the images in your organization’s repository, which should be the four public IBM images so far.$ cf ic images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE registry.ng.bluemix.net/ibm-node-strong-pm latest ef21e9d1656c 13 days ago 528.7 MB registry.ng.bluemix.net/ibmliberty latest 2209a9732f35 13 days ago 492.8 MB registry.ng.bluemix.net/ibmnode latest 8f962f6afc9a 13 days ago 429 MB registry.ng.bluemix.net/ibm-mobilefirst-starter latest 5996bb6e51a1 13 days ago 770.4 MB
- You will be using the IBM Containers plug-in. You can run
help
for more information$ cf ic help
- To create a container deploying the IBM Liberty container image again:
cf ic run --name container-lab-1 -p 9080 -m 64 registry.ng.bluemix.net/ibmliberty
where:-p
specifies the exposed port of the image, similar to the Ports field in Task 2, Step 9 above.When you specify a port, you are making the application available to the Bluemix Load Balancer and other containers attempting to access that port. If a port is specified in the Dockerfile for the image that you are using, include that port.For the IBM certified Liberty Server image, enter port 9080 via-p 9080
.
For the IBM certified Node.js, enter port 8000 viap 8000
.
If you plan on logging in to the container via SSH, add port 22 via-p 22
.--name
specifies the name you can use to refer to the container-m
specifies the memory limit (and associated storage capacity), similar to Task 2, Step 7 aboveregistry.ng.bluemix.net/ibmliberty
is the repository name for the image as displayed by the cf ic images command
- To check that the container has been deployed successfully, run the
cf ic ps -a
command to show all the container artifacts that have been created or deployed in your organization.$ cf ic ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES a055ba5e-77b registry.ng.bluemix.net/ibmliberty:latest "" 5 minutes ago Running 4 minutes ago 134.XXX.YYY.ZZZ:9080->9080/tcp container-lab-1
- Now you can assign a public IP to the container. The
cf ic run
command will proactively attempt to request and bind a public IP address for your container instance if there is room left in your IP Quota. By default, you have 2 Public IP addresses in your quota.If yourcf ic ps -a
command returns your Liberty container with ports in the form of134.XXX.YYY.ZZZ:9080->9080/tcp
, then your container already has an assigned Public IP address and you can skip the next step. - (Optional) You will first list all requested Public IP addresses and then bind an available IP address to your running container instance.
$ cf ic ip list -a Number of allocated public IP addresses: 2 IpAddress ContainerId 134.XXX.YYY.174 df6ba7fd-436e-4d57-a69b-4228e19cadc1 134.XXX.YYY.175
Choose an IP address that is not bound to a container. Note that in Bluemix, you are allocated 2 Public IPs free of charge. If you do not have any public IP addresses available to complete the lab, use the
cf ic ip release
command to release one. In a real environment, contact your Bluemix organization administrator to provision additional public IP addresses for your organization.Once you have identified the desired IP address (selecting 134.XXX.YYY.175 from above), you run the
cf ic ip bind
command to associate a running container instance to a public IP address. Thecf ic ip bind
command takes either the container name or the container ID as the second argument to support scriptable interactions.$ cf ic ip bind 134.XXX.YYY.175 container-lab-1 Successfully bound IP
- Validate access to the container through the browser. Run
cf ic ps -a
once again and copy the public IP address associated with your container. Enter this value into your browser via http://%5BPublic_IP_Address%5D:9080 and you should see the Welcome to Liberty landing page. - Since both the UI and the CLI are working with the same backend, you can view your newly CLI-created container instance in the UI as well. This can be done by returning to the Bluemix Dashboard.
- Click on CONTAINERS in the left-hand menu. Your dashboard is now filtered to show your running container instances. Clicking on the square with the
container-lab-1
title will take you to the container overview dashboard. From here you have access to the same Monitoring & Logging, as well as the controls available to Stop, Pause, Restart, & Delete containers.
Conclusion
Congratulations, you have successfully completed this IBM Containers lab! You learned how to work with IBM Containers, and deploy Docker images onto Bluemix through the UI & CLI.
Cleanup
If you plan to do another lab, you need to clean up your container instances. This can be done through the UI and the DELETE button on each container, or you can do this through the CLI with the cf ic rm -f [CONTAINER_NAME]
command.