Facing issue in running docker container

Hi there I want to install Metaphlan tool for metagenomic analysis in docker for that I have created an image and installed metaphlan in it using dockerfile. Than I run the container on first it properly printed the metaphlan command but its automatically stop sunning and exited. I don’t know why kindly help me out how to keep my container running and how to work in that container.

for dockerfile this was the content in it.

# Use the base Python image
FROM python:3.7

# Set the working directory inside the container

# Install MetaPhlAn 3.1.0
RUN pip install metaphlan==3.1.0

# Set the entry point to MetaPhlAn
COPY entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/entrypoint.sh
ENTRYPOINT ["metaphlan"]

CMD tail -f /dev/null

Kindly help me out in this. Regards.

Hello @umaramjid ,

it’s not clear how you are using this docker file to keep the container running.

could you please share more details steps with error.

I assumed and tried to reproduce like below.

docker file

#Use the base Python image
FROM python:3.7

#Set the working directory inside the container

#Install MetaPhlAn 3.1.0
RUN pip install metaphlan==3.1.0

#Set the entry point to MetaPhlAn
#COPY entrypoint.sh /usr/local/bin/
#RUN chmod +x /usr/local/bin/entrypoint.sh
ENTRYPOINT ["metaphlan"]

CMD ["tail", "-f ", "/dev/null"]


docker run --rm -it test bash           
usage: metaphlan --input_type {fastq,fasta,bowtie2out,sam} [--force]
                 [--bowtie2db METAPHLAN_BOWTIE2_DB] [-x INDEX]
                 [--bt2_ps BowTie2 presets] [--bowtie2_exe BOWTIE2_EXE]
                 [--bowtie2_build BOWTIE2_BUILD] [--bowtie2out FILE_NAME]
                 [--min_mapq_val MIN_MAPQ_VAL] [--no_map] [--tmp_dir]
                 [--tax_lev TAXONOMIC_LEVEL] [--min_cu_len]
                 [--min_alignment_len] [--add_viruses] [--ignore_eukaryotes]
                 [--ignore_bacteria] [--ignore_archaea] [--stat_q]
                 [--perc_nonzero] [--ignore_markers IGNORE_MARKERS]
                 [--avoid_disqm] [--stat] [-t ANALYSIS TYPE]
                 [--nreads NUMBER_OF_READS] [--pres_th PRESENCE_THRESHOLD]
                 [--clade] [--min_ab] [-o output file] [--sample_id_key name]
                 [--use_group_representative] [--sample_id value]
                 [-s sam_output_file] [--legacy-output] [--CAMI_format_output]
                 [--unknown_estimation] [--biom biom_output] [--mdelim mdelim]
                 [--nproc N] [--install] [--force_download]
                 [--read_min_len READ_MIN_LEN] [-v] [-h]
                 [INPUT_FILE] [OUTPUT_FILE]
metaphlan: error: the following arguments are required: --input_type

so the error seems improper usage of metaphlan
could you please share more about your error? how you are trying? how to reproduce the error?


1 Like

@alishah730 pointed you to the right direction. Changing the CMD instruction to use the “exec form” was also a good idea, however the issue is still not resolved, as you need to understand what an entrypoint and a command is. A command is usually the argument of the entrypoint. Using the exec form the final command was become this:

metaphlan tail -f /dev/null

I don’t know metaphlan, but that it doesn’t seem like a wrapper to execute arguments as commands sou you can’t pass a shell command to it.

The original Dockerfile however must have had this result:

metaplan /bin/sh -c "tail -f /dev/tail"

which is still wrong.

If you want to use metaphlan, that has to be used without a command or used as a command without the entrypoint. You also need to make sure that metaphlan is running in the foreground, otherwise it will stop immediately. I could continue, but I wouldn’t write a whole tutorial here so let’s start understanding the entrypoint and the cmd :slight_smile: If yalso hav a tutorial:

But the sourcecode doesn’t show the expeted result or explain anything, so you you don’t want to run the script, you can watch the video muted (it is Hungarian, but I am planning to translate it) but you can see what I am doing on the screen and what command has what result.