Tips and Tricks for Docker

Learn a few more tricks to make the most convenient use of Docker on our platform.

Running Locally

It is strongly advised that you first create an image of your Dockerfile locally. If everything works fine, then try moving it on to the platform. Docker’s own local software can also help you debug problems easily, so it’s a good idea to try that first.

Docker Hub

Docker Hub is a free online community where contributors have made safe and test Dockerfiles for different frameworks. Base images such as ubuntu, node, and gcc can also be found there. If you’re not sure about how to write a Dockerfile for a specific environment, check out how it’s done on Docker Hub. It will give you a good starting point.

Note: Dockerfiles found on Docker Hub may have to be slightly altered to run successfully on Educative. Use your own judgment while working with them.

Educative’s Base Image

Educative has its own base image, that comes with Python 2.7 and Node 8 installed in Linux. There are some slight optimizations in the base image that may improve build time. If your environment does not require different versions of Python and Node, you can go ahead and use this image!

Base Image Name

gcr.io/educative-exec-env/educative

Usage

FROM gcr.io/educative-exec-env/educative:latest

Base Image Support

Apart from Educative’s own base image, we strongly advise you to stick the ubuntu base image. Other images like node, gcc, and alpine are prone to errors.

Build Time

Ideally, your image should not take more than 10 minutes. Here are some tips to reduce the build time if you are facing issues regarding build timeouts.

  • Reduce the number of steps in the Dockerfile. Each command adds a layer to the Docker image, which increases build time. Minimize the steps by concatenating commands using the && operator.

  • If you are installing some program that takes a lot of time, consider using a public base image that has it pre-installed (can be found on Docker Hub). This will remove the installation time from your image.