If you wonder what an image and a container is, please see :
Building an image starts from a
Dockerfile which is a plain text file with instructions. Here an example which we are going to build:
It is based on the mambaforge image, so
mamba is already installed which we can then use to install our software.
mamba is a much faster alternative to
conda in case that is new to anyone.
The FROM line declares which image we use to build our image upon, here the mentioned mambaforge image.
The RUN line tells Docker which commands to run for the build, here it instructs to use
mamba to install
For the below steps we assume that Docker is installed and the Docker daemon is running.
1) Save the above chunk to your current directory as plain text named
2) Create an account at Dockerhub and then create a repository, here I created one named
biostars_9476707 with my username
3) Build the image, assuming the Dockerfile is in the current working directory:
docker build -t atpoint/biostars_9476707:v1.0.0 .
Here in this command
atpoint is my username at Dockerhub,
biostars_9476707 is the repository name to which the image will be uploaded (pushed) to, and
v1.0.0 is an optional tag. The tag serves as a version control, so if you make a change and push and updated version of the image you could name it
v1.0.1 and so on to keep track of it. The
. at the end of the command tells Docker to look in the current directory for the Dockerfile. One could also use something like:
docker build -t atpoint/biostars_9476707:v1.0.0 - < Dockerfile
In any case Docker will now build the image based on the instructions in the Dockerfile. This is not limited to installing software via conda. The
RUN chunks can run any Linux-compatible code, so you could compile software from source, or run
R command lines to compile R packages. For the sake of this tutorial lets limit on the conda commands though. The above build should not take longer than 30 seconds.
4) Push it to Dockerhub so it is available for download from any location. Again, as described in 2) by best knowledge this requires that the repository at the Hub as already been created manually, I do not know at this point whether one can automate this. Please comment if anyone knows that.
docker push atpoint/biostars_9476707:v1.0.0
The image is now available from Dockerhub at the repository you chose for download from any machine:
docker pull atpoint/biostars_9476707:v1.0.0
If you are ever going to work on a server or cluster where Docker is not allowed and Singularity is used, then you can seamlessly convert Docker images to the Singularity Image Format (SIF) via:
singularity pull docker://atpoint/biostars_9476707:v1.0.0
Read more here: Source link