# How can I build a custom docker image from qiime2-amplicon distribution?

**URL:** https://forum.qiime2.org/t/how-can-i-build-a-custom-docker-image-from-qiime2-amplicon-distribution/29457
**Category:** Technical Support
**Tags:** docker
**Created:** [March 2, 2024, 8:33pm UTC](https://forum.qiime2.org/t/how-can-i-build-a-custom-docker-image-from-qiime2-amplicon-distribution/29457 "2024-03-02T20:33:27Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![jolespin](https://forum.qiime2.org/user_avatar/forum.qiime2.org/jolespin/32/13951_2.png) [@jolespin](https://forum.qiime2.org/u/jolespin)
#### Post date: [March 2, 2024, 8:33pm UTC](https://forum.qiime2.org/t/how-can-i-build-a-custom-docker-image-from-qiime2-amplicon-distribution/29457/1 "2024-03-02T20:33:27Z")

</div>

I'm trying to build a custom docker container with specific volume mount locations using the qiime2-amplicon-2024.2 distribution.

Here's my docker file:

```auto
FROM mambaorg/micromamba:1.5.6

SHELL ["/usr/local/bin/_dockerfile_shell.sh"]

WORKDIR /tmp/

# Data
USER root
RUN mkdir -p /volumes/
RUN mkdir -p /volumes/input
RUN mkdir -p /volumes/output
RUN mkdir -p /volumes/database

# Retrieve repository
USER $MAMBA_USER
RUN micromamba install -y -n base -c conda-forge wget
ARG MAMBA_DOCKERFILE_ACTIVATE=1
RUN wget https://data.qiime2.org/distro/amplicon/qiime2-amplicon-2024.2-py38-linux-conda.yml

# Install dependencies
RUN micromamba install -y -n base -f /tmp/qiime2-amplicon-2024.2-py38-linux-conda.yml && \
    micromamba clean -a -y -f

RUN rm -rf /tmp/qiime2-amplicon-2024.2-py38-linux-conda.yml

ENTRYPOINT ["/usr/local/bin/_entrypoint.sh"]

```

However, I'm getting errors like this:

```auto
(base) Joshs-MBP:Containers jolespin$ docker build -t jolespin/qiime2-amplicon:2024.2 -f Dockerfile_qiime2-amplicon-2024.2 .
[+] Building 7.3s (13/14) docker:desktop-linux
 => [internal] load build definition from Dockerfile_qiime2-amplicon-2024.2 0.0s
 => => transferring dockerfile: 1.34kB 0.0s
 => [internal] load metadata for docker.io/mambaorg/micromamba:1.5.6 0.8s
 => [auth] mambaorg/micromamba:pull token for registry-1.docker.io 0.0s
 => [internal] load .dockerignore 0.0s
 => => transferring context: 2B 0.0s
 => [1/10] FROM docker.io/mambaorg/micromamba:1.5.6@sha256:4d9619e648abe569fd72fa30011c22bab13dd8494a7745295f512303de048989 0.0s
 => CACHED [2/10] WORKDIR /tmp/ 0.0s
 => CACHED [3/10] RUN mkdir -p /volumes/ 0.0s
 => CACHED [4/10] RUN mkdir -p /volumes/input 0.0s
 => CACHED [5/10] RUN mkdir -p /volumes/output 0.0s
 => CACHED [6/10] RUN mkdir -p /volumes/database 0.0s
 => CACHED [7/10] RUN micromamba install -y -n base -c conda-forge wget 0.0s
 => CACHED [8/10] RUN wget https://data.qiime2.org/distro/amplicon/qiime2-amplicon-2024.2-py38-linux-conda.yml 0.0s
 => ERROR [9/10] RUN micromamba install -y -n base -c qiime2 -c conda-forge -c bioconda -f /tmp/qiime2-amplicon-2024.2-py38-linux-conda.yml && 6.5s
------
 > [9/10] RUN micromamba install -y -n base -c qiime2 -c conda-forge -c bioconda -f /tmp/qiime2-amplicon-2024.2-py38-linux-conda.yml && micromamba clean -a -y -f:
0.184 conda-forge/linux-aarch64 Using cache
0.184 conda-forge/noarch Using cache
6.484 error libmamba Could not solve for environment specs
6.484 The following packages are incompatible
6.484 ├─ alsa-lib 1.2.8** is requested and can be installed;
6.484 ├─ bioconductor-ancombc 2.0.1** is not installable because it requires
6.484 │ └─ bioconductor-s4vectors >=0.36.0,<0.37.0 , which does not exist (perhaps a missing channel);
6.484 ├─ bioconductor-beachmat 2.14.0** does not exist (perhaps a typo or a missing channel);
6.484 ├─ bioconductor-biobase 2.58.0** does not exist (perhaps a typo or a missing channel);

```

I've tried manually adding the channel to the condarc but it still didn't work:

```auto
#RUN echo "channel_priority: flexible" >> ~/.condarc
#RUN echo "channels:" >> ~/.condarc
#RUN echo " - qiime2" >> ~/.condarc
#RUN echo " - conda-forge" >> ~/.condarc
#RUN echo " - bioconda" >> ~/.condarc

```

Any suggestions?

I'm seeing this Dockerfile here but miniconda is waaaay bigger than micromamba: [vm-playbooks/docker/Dockerfile at master · qiime2/vm-playbooks · GitHub](https://github.com/qiime2/vm-playbooks/blob/master/docker/Dockerfile)

---

<div class="post-metadata">

### Author: ![colinbrislawn](https://forum.qiime2.org/user_avatar/forum.qiime2.org/colinbrislawn/32/6221_2.png) [@colinbrislawn](https://forum.qiime2.org/u/colinbrislawn)
#### Post date: [March 3, 2024, 7:35pm UTC](https://forum.qiime2.org/t/how-can-i-build-a-custom-docker-image-from-qiime2-amplicon-distribution/29457/2 "2024-03-03T19:35:56Z")

</div>

Hello Josh,

> conda-forge/linux-aarch64

aarch64 is supported by conda-forge, but not bioconda.

> <https://github.com/bioconda/bioconda-utils/issues/706>
>
> I've heard from a user of my software that they are using it through bioconda on… a Mac M1. It would be great if they could use native bioconda packages for ARM64/Mac M1.
> 
> Conda-forge seems to support the following platforms (https://github.com/conda-forge/miniforge):
> \* Linux | x86\_64 (amd64)
> \* Linux | aarch64 (arm64)
> \* Linux | ppc64le (POWER8/9)
> \* OS X | x86\_64
> \* OS X | arm64 (Apple Silicon)
> \* Windows | x86\_64
> 
> It would be nice to be able to offer prebuilt bioconda packages for all of these platforms (except Windows I guess). The recipes I maintain would support all of these architectures already.

[https://github.com/bioconda/bioconda-recipes/issues/23454](https://github.com/bioconda/bioconda-recipes/issues/23454)

Are you _trying_ to run this on ARM or should this be an x86 machine?

---

<div class="post-metadata">

### Author: ![jolespin](https://forum.qiime2.org/user_avatar/forum.qiime2.org/jolespin/32/13951_2.png) [@jolespin](https://forum.qiime2.org/u/jolespin)
#### Post date: [March 3, 2024, 11:37pm UTC](https://forum.qiime2.org/t/how-can-i-build-a-custom-docker-image-from-qiime2-amplicon-distribution/29457/3 "2024-03-03T23:37:48Z")

</div>

I’ve made some progress on this and I need to update this issue when I get home. I added the full url for conda channel like in the official dockerfile which helped. However, the last issue I ran into was getting past outdated certificates during the install command within the dockerfile. I’ll get exact details in a bit.

Getting this to work with micromamba should really reduce the file size by quite a bit for the container.

For context, I am building this an Apple silicon machine (m2 pro) using Rosetta in my terminal (emulating intel). I plan on using the image on AWS batch.

---

<div class="post-metadata">

### Author: ![colinbrislawn](https://forum.qiime2.org/user_avatar/forum.qiime2.org/colinbrislawn/32/6221_2.png) [@colinbrislawn](https://forum.qiime2.org/u/colinbrislawn)
#### Post date: [March 5, 2024, 6:13pm UTC](https://forum.qiime2.org/t/how-can-i-build-a-custom-docker-image-from-qiime2-amplicon-distribution/29457/4 "2024-03-05T18:13:09Z")

</div>

Sup Josh,

Your timing is impeccable; [it looks like](https://github.com/bioconda/bioconda-recipes/issues/23454) bioconda just rolled out aarch64 support for Linux, though there's no osx-arm64 support yet.

If you are using AWS batch with x86, it probably makes more sense to build on that instead of trying to build on osx-arm64 and then ship the container...

(Our lead deployment engineer is out right now, so I appreciate your patience. Once she is back, we can get her advice about this topic.)

---

<div class="post-metadata">

### Author: ![jolespin](https://forum.qiime2.org/user_avatar/forum.qiime2.org/jolespin/32/13951_2.png) [@jolespin](https://forum.qiime2.org/u/jolespin)
#### Post date: [March 5, 2024, 6:26pm UTC](https://forum.qiime2.org/t/how-can-i-build-a-custom-docker-image-from-qiime2-amplicon-distribution/29457/6 "2024-03-05T18:26:23Z")

</div>

This did the trick for me:

```auto
# v2024.3.4
# =============================
FROM --platform=linux/amd64 mambaorg/micromamba:1.5.6

SHELL ["/usr/local/bin/_dockerfile_shell.sh"]

WORKDIR /tmp/

# Data
USER root
RUN mkdir -p /volumes/
RUN mkdir -p /volumes/input
RUN mkdir -p /volumes/output
RUN mkdir -p /volumes/database

ENV LC_ALL C.UTF-8
ENV LANG C.UTF-8
ENV MPLBACKEND agg
ENV XDG_CONFIG_HOME /home/qiime2

# Retrieve repository
USER $MAMBA_USER
RUN micromamba install -y -n base -c conda-forge wget ca-certificates

ARG MAMBA_DOCKERFILE_ACTIVATE=1
RUN wget --no-check-certificate https://data.qiime2.org/distro/amplicon/qiime2-amplicon-2024.2-py38-linux-conda.yml

# Install dependencies
RUN micromamba install -y -n base \
    -c https://packages.qiime2.org/qiime2/2024.2/amplicon/released \
    -c bioconda \
    -c conda-forge \
    -c defaults \
    -f /tmp/qiime2-amplicon-2024.2-py38-linux-conda.yml && \ 
    micromamba clean -a -y -f

RUN rm -rf /tmp/qiime2-amplicon-2024.2-py38-linux-conda.yml
# RUN qiime dev refresh-cache

ENTRYPOINT ["/usr/local/bin/_entrypoint.sh"]

```

However, I had to remove `qiime dev refresh-cache` because it was taking over a day to run just that step.

The micromamba installation is a little smaller but not as much as I thought it would be at 5.13GB compared to 5.92GB.

---

<div class="post-metadata">

### Author: ![colinbrislawn](https://forum.qiime2.org/user_avatar/forum.qiime2.org/colinbrislawn/32/6221_2.png) [@colinbrislawn](https://forum.qiime2.org/u/colinbrislawn)
#### Post date: [March 5, 2024, 6:31pm UTC](https://forum.qiime2.org/t/how-can-i-build-a-custom-docker-image-from-qiime2-amplicon-distribution/29457/7 "2024-03-05T18:31:46Z")

</div>

Great!

Would you like me to leave this thread open to get comments from the Qiime devs, or close it for now?

I'm personally curious about the need for custom containers instead of the default ones on [Quay](https://quay.io/qiime2/), if you are willing to share more context.

---

<div class="post-metadata">

### Author: ![system](https://forum-qiime2-org.s3.dualstack.us-west-2.amazonaws.com/original/3X/2/1/21af5fe23cb6f4579467c66a9ed94e55274ca7bd.svg) [@system](https://forum.qiime2.org/u/system)
#### Post date: [April 6, 2024, 1:49am UTC](https://forum.qiime2.org/t/how-can-i-build-a-custom-docker-image-from-qiime2-amplicon-distribution/29457/9 "2024-04-06T01:49:46Z")

</div>

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
