Containers are a standard way to package an application and all its dependencies so that it can be moved between environments and run without change. They work by hiding the differences between applications inside the container so that everything outside the container can be standardized.
For example, Docker created standard way to create images for Linux Containers.
|Get Docker version|
|List Running Containers|
|Stop a container|
|List Docker Images|
|Login into registry|
|Build an image|
|Inspect a docker object|
|Inspect a docker image|
|Pull an image|
|Push an Image|
|Remove a container|
- Make sure you are logged in to your Kubernetes cluster through a terminal or IBM Cloud Shell.
- Next, we need to apply the yaml file for the Docker in Docker pod.kubectl apply -f https://raw.githubusercontent.com/ibm-cloud-architecture/learning-cloudnative-101/master/static/yamls/containers/dind.yaml
- Then, we need to bash into the running pod.kubectl exec -it dind bash
- Finally check to make sure you can run docker commands, such as docker version
- Check the Docker Versiondocker version
- Run the `hello-world` containerdocker run hello-world
- Check the output:
Hello from Docker!
This message shows that your installation appears to be working correctly!....
- Check the Docker Version
- Start and nginx container and name it `nginx`.docker run --rm -d --name nginx -p 8080:8080 bitnami/nginx
- Check to see if the container is runningdocker ps
- Bash into the running nginx containerdocker exec -it nginx bash
- Accessing the running nginx containercurl http://localhost:8080
- Stopping the nginx containerdocker stop nginx
- Start and nginx container and name it `nginx`.
- Let's start by creating a directory named assets and add an index.html file to it. mkdir -p assets; echo "Welcome to the Cloud Native BootCamp" > assets/index.html; cd assets
- Download the sample Dockerfile into the assets directory.wget https://raw.githubusercontent.com/ibm-cloud-architecture/learning-cloudnative-101/master/static/yamls/containers/Dockerfile
- Build the docker image and name it webserver with a tag of 1.0.docker build -t webserver:1.0 .
- Run the new image in a container.docker run --rm -d -p 8000:8080 webserver:1.0
- Access the new containercurl http://localhost:8000
- Let's start by creating a directory named assets and add an index.html file to it.
- Login to Docker Hub using YOUR created username and password.docker login -u USERNAME -p PASSWORD
- Tag the docker image with docker hub usernamedocker tag webserver:1.0 USERNAME/webserver:1.0
- Push the image to the registrydocker push USERNAME/webserver:1.0
- Run the new imagedocker run --rm -p 8000:8080 USERNAME/webserver:1.0
- You can also pull down other images from other users.docker pull USERNAME/webserver:1.0
- Login to Docker Hub using YOUR created username and password.
- Create a Docker filedocker run --rm --name nginx -e USERNAME=Carlos -e PASSWORD=IlikeYAML -e LOG_LEVEL=ERROR -p 8080:8080 bitnami/nginx
- Create a Docker filedocker exec -it nginx sh -c "env | grep 'USERNAME\|PASSWORD\|LOG_LEVEL'"
- Create a Docker file
- Run the image with a volume attached.docker run --rm --name nginx -p 8080:8080 -v $PWD/assets:/app bitnami/nginx
- Run the image with a volume attached.
|What is a Container?||A look under the the covers at what is a Linux Container?||Understand Containers||10 min|
|What is an Image?||A look under the the covers at what is a Linux Container Image?||Container Images||10 min|
|Docker Basics||Set of walkthroughs that cover docker basics||Docker Basics||10 min|
|Try It Yourself|
|IBM Container Registry||Build and Deploy Run using IBM Container Registry||IBM Container Registry||30 min|
|Docker Lab||Running a Sample Application on Docker||Docker Lab||30 min|
Once you have completed these tasks, you should have a base understanding of containers and how to use Docker.