In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "how to create an image through Dockerfile". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to create an image through Dockerfile".
/ / list all local container images
$docker imagesREPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZEtraining/webapp latest fc77f57ad303 3 weeks ago 280.5 MBubuntu 14.04 5e019ab7bf6d 4 weeks ago 180 MBubuntu latest 5e019ab7bf6d 4 weeks ago MBubuntu 12.04 74fe38d11401 4 weeks ago 209.6 MBubuntu precise 74fe38d11401 4 weeks ago 209.6 MB
/ / there may be multiple TAG in an image
/ / run a container via docker run-t-I REPOSITORY:TAG / bin/bash, for example, ubuntu:14.04 and ubuntu:latest are running the same image
/ / get a new container image
$docker pull centosPulling repository centosb7de3133ff98: Pulling dependent layers5cc9e91966f7: Pulling fs layer511136ea3c5a: Download completeef52fb1fe610: Download complete. . .status: Downloaded newer image for centos$ docker run-t-I centos / bin/bashbash-4.1#
/ / search the desired container image from Docker Hub
$sudo docker search sinatraNAME DESCRIPTION STARS OFFICIAL AUTOMATEDtraining/sinatra Sinatra training image 0 [OK] marceldegraaf/sinatra Sinatra test app 0mattwarren/ Docker-sinatra-demo 0 [OK] luisbebop/docker-sinatra-hello-world 0 [OK] bmorearty/handson-sinatra handson-ruby + Sinatra for Hands on with D. 0subwiz/sinatra 0bmorearty/sinatra 0. . . / / then you can download the appropriate container image
/ / create a custom container image
$docker run-t-I training/sinatra / bin/bashroot@0b2616b0e5a8:/# gem install json
/ /-an identify the creator $docker commit-m "Added json gem"-a "Kate Smith" 0b2616b0e5a8 ouruser/sinatra:v24f177bd27a9ff0f6dc2a830403925b5360bfe0b93d476f7fc3231110e7f71b1c
/ / View the created container image
$docker imagesREPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZEtraining/sinatra latest 5bc342fa0b91 10 hours ago 446.7 MBouruser/sinatra v2 3c59e02ddd1a 10 hours ago 446.7 MBouruser/sinatra latest 5db5f8471261 10 hours ago 446.7 MB
/ / create an image through Dockerfile
$mkdir sinatra$ cd sinatra$ touch Dockerfile# This is a commentFROM ubuntu:14.04MAINTAINER Kate Smith RUN apt-get update & & apt-get install-y ruby ruby-devRUN gem install sinatra
/ / create an image using Dockerfile and docker build commands
$docker build-t ouruser/sinatra:v2 .Sending build context to Docker daemon 2.048 kBSending build context to Docker daemon Step 0: FROM ubuntu:14.04-> e54ca5efa2e9Step 1: MAINTAINER Kate Smith-> Using cache-> 851baf55332bStep 2: RUN apt-get update & & apt-get install-y ruby ruby-dev-- > Running in 3a2558904e9bSelecting previously unselected package libasan0:amd64....
Installing RDoc documentation for rack-protection-1.5.3...Installing RDoc documentation for sinatra-1.4.5... -> 97feabe5d2edRemoving intermediate container 6b81cb6313e5Successfully built 97feabe5d2ed// uses-t to identify whether the new image belongs to ouruser,v2 or TAG
/ / set TAG for ouruser/sinatra image
$docker tag 5db5f8471261 ouruser/sinatra:devel
/ / View the TAG of ouruser/sinatra
$docker images ouruser/sinatraREPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZEouruser/sinatra latest 5db5f8471261 11 hours ago 446.7 MBouruser/sinatra devel 5db5f8471261 11 hours ago 446.7 MBouruser/sinatra v2 5db5f8471261 11 hours ago 446.7 MB
/ / PUSH the image to Docker Hub
$docker push ouruser/sinatraThe push refers to a repository [ouruser/sinatra] (len: 1) Sending image listPushing repository ouruser/sinatra (3 tags). . .
/ / Delete the image locally
$docker rmi training/sinatraUntagged: training/sinatra:latestDeleted: 5bc342fa0b91cabf65246837015197eecfa24b2213ed6a51a8974ae250fedd8dDeleted: ed0fffdcdae5eb2c3a55549857a8be7fc8bc4241fb19ad714364cbfd7a56b22fDeleted: 5c58979d73ae448df5af1d8142436d81116187a7633082650549c52c3a2418f0 Thank you for your reading. The above is the content of "how to create an image through Dockerfile". After the study of this article, I believe you have a deeper understanding of how to create an image through Dockerfile, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.