maxbit89
maxbit89

Reputation: 770

Docker create independent image

Hy i build a little image for docker on top of the debian:jessie image form the Docer Hub. First i got debian:jessie from Docker Hub:

docker pull debian:jessie

Then I startet this image with a bash:

docker run -it debian:jessie

Then I installed my stuff e.g. ssh server and configured it. Next from a second shell, i commitet the changes:

docker commit <running container id> debian-sshd

Now i have two images:

debian:jessie and debian-sshd

If i now want to delete debian:jessie, docker tells me i can't delete this because it has child-images(debian-sshd)

Is There a way I can make debian-sshd an independent image?

Upvotes: 1

Views: 1594

Answers (1)

Ayushya
Ayushya

Reputation: 10447

Most Dockerfiles start from a parent image. If you need to completely control the contents of your image, you might need to create a base image instead. Here’s the difference:

  • A parent image is the image that your image is based on. It refers to the contents of the FROM directive in the Dockerfile. Each subsequent declaration in the Dockerfile modifies this parent image. Most Dockerfiles start from a parent image, rather than a base image. However, the terms are sometimes used interchangeably.

  • A base image either has no FROM line in its Dockerfile, or has FROM scratch.

Having quoted from docs, I would say that images are made up of layers, and since you have based your image on debian:jessie, one of the layers of debian-sshd is the debian:jessie image. If you want your independent image, build from scratch.

Other then that, all docker images are open source, so you can browse the dockerfile and modify it to suit your needs. Also, you could build from scratch if you want your own base image.

Upvotes: 2

Related Questions