The Methods for Creating Container Images
There are two main methods for creating a container image:
1. Get the image through a snapshot.
2. Build the image using Dockerfile.
The first method is applicable when subsequent images do not change, and the second one is applicable when subsequent images change frequently.
Method 1: Obtain the image through a snapshot
1. Install the container engine software.
2. Start a blank basic container and enter it.
3. Perform the installation tasks:
yum install XXX
git clone https://github.com/lh3/bwa.git
cd bwa;make
4. Exit the container:
5. Make a snapshot:
docker commit -m "xx" -a "test" container-id test/image:tag
6. View the created container image:
Method 2: Build the image using Dockerfile
Method 2 is applicable to situations where subsequent images are frequently changed. It automates the creation of images by executing the Dockerfile.
For example:
FROM ubuntu:latest
SHELL ["/bin/bash", "-c"]
RUN set -e \\
&& apt-get -y update \\
&& apt-get -y dist-upgrade \\
&& apt-get -y install curl build-essential libncurses5-dev zlib1g-dev libbz2-dev liblzma-dev libcurl4-openssl-dev \\
&& apt-get -y autoremove \\
&& apt-get clean \\
&& rm -rf /var/lib/apt/lists/*
RUN set -eo pipefail \\
&& curl -SL \\
https://github.com/samtools/samtools/releases/download/1.15/samtools-1.15.tar.bz2 \\
-o /tmp/samtools.tar.bz2 \\
&& tar xvf /tmp/samtools.tar.bz2 -C /usr/local/src \\
&& mv /usr/local/src/samtools-* /usr/local/src/samtools \\
&& cd /usr/local/src/samtools \\
&& ./configure --prefix=/usr/local \\
&& make \\
&& make install
Was this page helpful?