Docker Desktop Build Container Tutorial: Difference between revisions

From WikiMLT
m (Стадий: 3 [Фаза:Разработване, Статус:Разработван]; Категория:Containers)
mNo edit summary
Line 1: Line 1:
<noinclude><!--[[Category:Hardware|?]]-->{{ContentArticleHeader/Containers}}</noinclude>
<noinclude><!--[[Category:Hardware|?]]-->{{ContentArticleHeader/Containers}}</noinclude>
== References ==
'''''This time (Feb 2023) I was need to install and use Docker on MacOS. Here are the steps provided by the default Docker Desktop Tutorial on MacOS.'''''


* ...
The ''Getting Started'' project is a simple GitHub repository which contains everything you need to build an image and run it as a container.


* ...
== First, clone a repository ==
Clone the repository by running Git in a container.<syntaxhighlight lang="shell" line="1">
docker run --name repo alpine/git \
clone https://github.com/docker/getting-started.git
docker cp repo:/git/getting-started/ .
</syntaxhighlight>You can also type the command directly in a command line interface.


== Section 1 ==
== Now, build the image ==
A Docker image is a private file system just for your container. It provides all the files and code your container needs.<syntaxhighlight lang="shell" line="1">
cd getting-started
docker build -t docker101tutorial .
 
</syntaxhighlight><syntaxhighlight lang="shell-session">
...
...
Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them.
</syntaxhighlight>
== Run your first container ==
Start a container based on the image you built in the previous step. Running a container launches your application with private resources, securely isolated from the rest of your machine.<syntaxhighlight lang="shell" line="1">
docker run -d -p 80:80 --name docker-tutorial docker101tutorial
</syntaxhighlight>''Then visit http://localhost/, where a nice tutorial should be displayed!''
== Now save and share your image ==
''You must be signed in to Docker Hub to share your image. [https://hub.docker.com/auth/desktop/redirect?code=f8sfu6bvWWihlbBDU4Q3IRnJVL6XswdDIDc3S6MFPzes-&state=dgsVaAoQL2-fhvgIRWkXr1QKGUsP6ZU__cD5nrNI_uM Sign in here].''
Save and share your image on Docker Hub to enable other users to easily download and run the image on any destination machine.<syntaxhighlight lang="shell" line="1">
dockdocker tag docker101tutorial pa4080/docker101tutorial
docker push pa4080/docker101tutorial
</syntaxhighlight>''Finally:'' [https://hub.docker.com/repositories/pa4080 See what you've saved on Hub].
== Docker Desktop References ==
* Docker Docs: [https://docs.docker.com/desktop/install/mac-install/ Install Docker Desktop on Mac]
* Docker Docs: [https://docs.docker.com/desktop/backup-and-restore/ Back up and restore data]
* Docker Docs: [https://docs.docker.com/get-started/ '''Get started''']
* See also: [https://hub.docker.com/ hub.docker.com]


<noinclude>
<noinclude>

Revision as of 12:50, 23 February 2023

This time (Feb 2023) I was need to in­stall and use Dock­er on Ma­cOS. Here are the steps pro­vid­ed by the de­fault Dock­er Desk­top Tu­to­r­i­al on Ma­cOS.

The Get­ting Start­ed project is a sim­ple GitHub repos­i­to­ry which con­tains every­thing you need to build an im­age and run it as a con­tain­er.

First, clone a repos­i­to­ry

Clone the repos­i­to­ry by run­ning Git in a con­tain­er.

docker run --name repo alpine/git \
clone https://github.com/docker/getting-started.git
docker cp repo:/git/getting-started/ .

You can al­so type the com­mand di­rect­ly in a com­mand line in­ter­face.

Now, build the im­age

A Dock­er im­age is a pri­vate file sys­tem just for your con­tain­er. It pro­vides all the files and code your con­tain­er needs.

cd getting-started
docker build -t docker101tutorial .
...
Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them.

Run your first con­tain­er

Start a con­tain­er based on the im­age you built in the pre­vi­ous step. Run­ning a con­tain­er launch­es your ap­pli­ca­tion with pri­vate re­sources, se­cure­ly iso­lat­ed from the rest of your ma­chine.

docker run -d -p 80:80 --name docker-tutorial docker101tutorial

Then vis­it http://localhost/, where a nice tu­to­r­i­al should be dis­played!

Now save and share your im­age

You must be signed in to Dock­er Hub to share your im­age. Sign in here.

Save and share your im­age on Dock­er Hub to en­able oth­er users to eas­i­ly down­load and run the im­age on any des­ti­na­tion ma­chine.

dockdocker tag docker101tutorial pa4080/docker101tutorial
docker push pa4080/docker101tutorial

Fi­nal­ly: See what you've saved on Hub.

Dock­er Desk­top Ref­er­ences