How to give a name to an image in Dockerfile ?

0 votes

I know that I can give the image name when building a custom image, like this:

docker build -t sam/can:v2 . # Will be named sam/can:v2

I wanted to know if I can define the name of the image in Dockerfile, so I won't have to mention it in the docker build command?

Can anyone help me with this?

Thanks.

Nov 16, 2018 in DevOps & Agile by Shubham
• 1,000 points
94 views

1 answer to this question.

0 votes

This needs to be done in your build command.Here is what you can try. 

You can  build a docker-compose.yml that will identify the target image name and then run a docker-compose build. A sample docker-compose.yml would look like

version: '2'

services:
  man:
    build: .
    image: sam/can:v2

I hope this is what you are looking for.

answered Nov 16, 2018 by Damon Salvatore
• 5,510 points

Related Questions In DevOps & Agile

0 votes
1 answer

How to a run deployed app in Docker for Windows?

To deploy an ASP.NET web application to ...READ MORE

answered Aug 29, 2018 in DevOps & Agile by Tyrion anex
• 8,270 points
119 views
+2 votes
1 answer

What is the difference between a container and an image in Docker?

 Below is reference which you can follow to know ...READ MORE

answered Sep 20, 2018 in DevOps & Agile by shubham
• 6,890 points
54 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 56,520 points
149 views
0 votes
1 answer
0 votes
1 answer