How to create named and latest tag in Docker?

后端 未结 6 776
北海茫月
北海茫月 2020-12-04 05:17

Supposed I have an image that I want to tag as 0.10.24 (in my case it\'s an image containing Node.js 0.10.24). I built that image using a Dockerfile and executi

6条回答
  •  佛祖请我去吃肉
    2020-12-04 05:29

    Just grep the ID from docker images:

    docker build -t creack/node:latest .
    ID="$(docker images | grep 'creak/node' | head -n 1 | awk '{print $3}')"
    docker tag "$ID" creack/node:0.10.24
    docker tag "$ID" creack/node:latest
    

    Needs no temporary file and gives full build output. You still can redirect it to /dev/null or a log file.

提交回复
热议问题