KenJohns
KenJohns

Reputation: 43

Docker run command from git repo?

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?

Upvotes: 3

Views: 2239

Answers (1)

VonC
VonC

Reputation: 1323135

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).

Upvotes: 3

Related Questions