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?


Nov 16, 2018 in DevOps & Agile by Shubham
• 980 points

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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'

    build: .
    image: sam/can:v2

I hope this is what you are looking for.

answered Nov 16, 2018 by Damon Salvatore
• 5,250 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,280 points
+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,480 points
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,120 points
0 votes
1 answer
0 votes
1 answer

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.