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
1,233 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 17, 2018 by Damon Salvatore
• 5,980 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 30, 2018 in DevOps & Agile by Tyrion anex
• 8,700 points
877 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
• 7,340 points
888 views
0 votes
1 answer
0 votes
1 answer
+2 votes
1 answer
+2 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
• 58,090 points
2,435 views
0 votes
1 answer

How do I push a docker image to a private repository?

Here is what you can do. Just try ...READ MORE

answered Sep 19, 2018 in DevOps & Agile by Damon Salvatore
• 5,980 points
1,214 views
0 votes
1 answer

How do I assign a port mapping to an existing Docker container?

Below are some steps which you can ...READ MORE

answered Sep 19, 2018 in DevOps & Agile by Damon Salvatore
• 5,980 points
9,052 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP