Difficulty: Beginner
Estimated Time: 10 minutes

Don’t stop now! The next scenario will only take about 10 minutes to complete.

Building Container Images with Img

Like Buildah, Img is a CLI command for building OCI Images. The advantage of IMG is that is can be run by non-root users, making it ideal for running inside of a Container.

img

Clone a example HTTP Server which includes a Dockerfile.

git clone https://github.com/katacoda/golang-http-server.git && cd golang-http-server/ && cat Dockerfile

Using Img, build and tag the OCI Image.

img build -t [[HOST_SUBDOMAIN]]-5000-[[KATACODA_HOST]].environments.katacoda.com/http-server .

With the CLI, this can be pushed to a Docker Registry.

img push [[HOST_SUBDOMAIN]]-5000-[[KATACODA_HOST]].environments.katacoda.com/http-server

This can be pulled and started via Docker.

docker run -d -p 80:80 [[HOST_SUBDOMAIN]]-5000-[[KATACODA_HOST]].environments.katacoda.com/http-server

Test that the container has been built correctly

curl localhost