How to create a custom image from a Docker container


Getting your own custom image makes working with containers easier and it adds an extra layer of security. Jack Wallen shows you how.

docker-with-waves.jpg
Illustration: Lisa Hornung/TechRepublic

Your containers are all based on images, most of which you probably pull from DockerHub or some other public repository. But why not create your own custom images? After all, it’s easier for you to not only get the exact image you need to work with, it’s also a better route to security. It’s also a great way to create a base image you can use for a repeatable development environment (so, it has exactly the tools you need).

SEE: 40+ open source and Linux terms you need to know (TechRepublic Premium)

I’m going to show you how you can do just that–create an image from a container using the Docker runtime engine.

What you’ll need

I’ll be demonstrating on Ubuntu Server 20.04, but you can pull this off on any platform that supports Docker. The only thing you’ll need to alter is the Docker installation process. You’ll also need a user with sudo privileges (for the installation).

With that said, let’s get to work.

How to install Docker

Let’s first get Docker installed. We’ll install the latest version of the community edition of Docker. Log into your server and install the necessary dependencies with:

sudo apt-get install ca-certificates curl gnupg lsb-release -y

Once that completes, add the Docker GPG key:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

Next, add the Docker repository with the command:

echo 
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu 
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Update apt and install Docker-ce with:

sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io -y

Add your user to the Docker group with:

sudo usermod -aG docker $USER

Log out and log back in for the changes to take effect.

How to create your base container

We’re going to use the official Ubuntu image to create our container (which will be used to create the new image). Let’s pull down the latest version of Ubuntu from DockerHub and create a container named ubuntu-test with the command:

docker run -ti --name=ubuntu-test ubuntu:latest

At this point, you should find yourself at the bash prompt of the running Ubuntu container. Let’s say this new image will be used for Java development. Install the latest Java runtime environment. First update apt with:

apt-get update

Next, install the latest JRE with:

apt-get install default-jre -y

After the installation completes, exit from the container with:

exit

How to create the new image

The first thing to be done is to create a commit for the running container. Do this with:

docker commit ubuntu-test

Next, we need to locate the container ID for our running instance with the command:

docker ps -a

Start the container with:

docker start ID

Where ID is the container ID for ubuntu-test.

Next, we need to find the image ID with the command:

docker images

When we made the commit earlier, it created an image without a tag or name. You’ll see an image listed with <none> as both the ID and name. That’s the image we want to tag. Using the first four characters of the image ID of the new image, tag it with:

docker tag ID ubuntu-test-base

Where ID is the first four characters of the container ID for ubuntu-test. Now, if you issue the command docker images, you’ll see your new image with the name ubuntu-test-base. You could then deploy a new container, using that new image, with a command like:

docker create --name ubuntu-jre ubuntu-test-base

And that’s all there is to creating a custom Docker image, based on a modified container.

Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the latest tech advice for business pros from Jack Wallen.

 

 



Source link

istanbul escort aksaray escort arnavutköy escort ataköy escort avcılar escort avcılar türbanlı escort avrupa yakası escort bağcılar escort bahçelievler escort bahçeşehir escort bakırköy escort başakşehir escort bayrampaşa escort beşiktaş escort beykent escort beylikdüzü escort beylikdüzü türbanlı escort beyoğlu escort büyükçekmece escort cevizlibağ escort çapa escort çatalca escort esenler escort esenyurt escort esenyurt türbanlı escort etiler escort eyüp escort fatih escort fındıkzade escort florya escort gaziosmanpaşa escort güneşli escort güngören escort halkalı escort ikitelli escort istanbul escort kağıthane escort kayaşehir escort küçükçekmece escort mecidiyeköy escort merter escort nişantaşı escort sarıyer escort sefaköy escort silivri escort sultangazi escort suriyeli escort şirinevler escort şişli escort taksim escort topkapı escort yenibosna escort zeytinburnu escort porno 1080p porno izle 4k porno izle 720p porno izle abella danger alman alman porno alman porno izle aloha tube porno amatör amatör porno amatör porno izle anal anal porno anal porno izle arap porno asa akira porno asyalı porno bangbros porno bangbros porno izle banyoda sikis başörtülü porno beeg porno izle beyaz tenli porno izle biseksuel porno izle bisexsuel porno brandi love porno brazzers brazzers porno izle canli porno canli porno izle çinli porno çinli porno izle ensest porno ensest porno izle ensest seks erotik porno erotik porno izle esmer porno esmer porno izle etek altı fake agent fake taxi fake taxi porno fantazi pornoları fantezi porno izle fetiş porno fetiş porno izle fetish fransız porno fransız porno izle full hd hg porno izle gangbang porno genç kız porno izle genç kız sikişi genç teen porno izle gizli çekim porno gizli çekim pornosu grup pornosu grup porno grup porno izle hd pornolar hd porno hd porno izle hemşire porno hemşire pornosu hizmetçi porno hizmetçi porno izle ingiliz porno japon pornoları japon porno kızlık bozma kızlık bozma porno izle konulu porno konulu porno izle koreli porno köylü pornoları kumral porno kumral porno izle latin pornoları latin porno latin porno izle lezbiyen pornoları lezbiyen porno lezbiyen porno izle lisa ann porno liseli pornoları liseli porno liseli porno izle manken porno manken porno izle masaj porno izle masturbasyon porno izle masturbasyon pornoları mature porno mia khalifa porno mia malkova porno milf porno izle mobil porno mobil porno izle öğrenci porno izle öğretmen porno izle okul porno izle olgun kadın pornosu olgun porno oral porno oral porno izle oral seks porna izle pornhub pornhub porno izle porno film izle porno indir porno izle porno resimler porno star porntube porno izle redtube redtube pornoları riley reid porno rokettube rus pornoları rus porno rus porno izle sakso blowjob porno izle sarışın pornoları sarışın porno sarışın porno izle sarışın pornoları sekreter porno shemale sikiş sikiş sikiş izle şişman porno siyahi pornoları suriyeli pornoları swinger porno tecavüz porno teen porn türbanlı pornoları türbanlı porno türk pornoları türk porno türk porno izle türkçe altyazılı porno türkçe altyazılı porno izle xhamster pornoları xhamster porno xhamster porno izle xnxx xnxx porno xnxx porno izle xvideos xvideos porno izle yaşlı porno yeşilçam porno izle youjizz youporn youporn porno izle zenci porno güvenilir bahis siteleri bahis siteleri casino deneme bonusu casino siteleri deneme bonusu para yatırma bonusu bahis siteleri casino siteleribahis sitesi para yatırma