3

Let's say that I have a git repo which contains my new files and docker files (and others) from other git repo.
I want to clone this repo to my own local machine, and then I want to build this repo with docker. So I'll execute

docker build -t name:v1 cloned-folder/ 

But, after that, when I type docker images I get two images: name:v1 and image from the repo.

I want only have my image. How to do that without uploading to docker.hub?

Or maybe there is an option to run new container from cloned files without build?

1 Answer 1

3

If your Dockerfile starts with "FROM <image>", then docker images will always shows both <image> (the base image) and name:v1.

The fact that the Dockerfile is managed in a git repo is not important.

The OP adds:

git clone URL_to_my_repo and this repo contains repo mentioned earlier with my extra own files.
Then docker build -q -t mynewimage:v1 cloned_folder/.
after that I get two images when I type docker images

  • image from the FROM section of Dockerfile and
    • mynewimage:v1.
      What I want is to have only one image: mynewimage:v1.

That is expected (to see 2 images): your second one is built from the layers of the first one: you need both in order for mynewimage to work (because of the union filesystem).

Sign up to request clarification or add additional context in comments.

8 Comments

Hmm... Let's look on example: github.com/setiseta/docker-librenms there is a docker file that also contains FROM section. When i RUN that i get only one image. Why ? one difference is that I use also docker build.
@KenJohns you did not mention RUN in your question. You mentioned docker build.
@KenJohns What do you type exactly. What do you see as an exact output? (exact and complete copy/paste)
OK. With link mentioned earlier i just copy/paste everything on that site (so just RUN command with options) and i get one image (from the FROM sections) and one container. If we are talking about my repo: I clone my repo, build with 'docker build' command that cloned repo, i get two images: one from dockerfile (same as on that link) and second one - created by 'docker build'; and then i execute 'docker run' command with the image id (created by me).
@KenJohns RUN is a Dockerfile directive, do you mean docker run
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.