Dockerfiles in Code Ocean

What is a Dockerfile?

Code Ocean uses Docker to create the software environment for a capsule. A Dockerfile is a document that contains all the commands required to assemble the environment.

How to create a Dockerfile in Code Ocean

Within a capsule, click on the environment directory in the file tree system to open the Environment Editor. This is a user-friendly interface that allows you to create a Dockerfile without needing to know any Docker syntax. First, select your preferred starter environment (the base image), and then customize it further using the package manager.

To manually customize your capsule environment you can open the Dockerfile and unlock it. This is not recommended as it will permanently disable the environment editor and all subsequent changes to the environment will need to be made through the Dockerfile.

How to adapt an existing Dockerfile to Code Ocean

When adapting an existing project to Code Ocean, you may already have a Dockerfile that you’d like to use. In this case, you could:

  • Parse your local Dockerfile and add each comment to your capsule's Dockerfile with the environment editor

  • Put all of your dependencies in a requirements.txt or environment.yml file, click the gear icon next to the appropriate package manager, select edit bulk and upload your file. Learn more in the Packages and Package Managers section of the documentation.

When to create a custom Docker image

If the Code Ocean starter environments don't provide for your specific requirements, contact your administrator to create a custom Docker image for you.

Last updated