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
• 1,000 points

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'

    build: .
    image: sam/can:v2

I hope this is what you are looking for.

answered Nov 16, 2018 by Damon Salvatore
• 5,540 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,380 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,910 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
• 57,530 points
0 votes
1 answer
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 18, 2018 in DevOps & Agile by Damon Salvatore
• 5,540 points