Docker Desktop Build Container Tutorial: Difference between revisions

From WikiMLT
m (Стадий: 4 [Фаза:Авторизиране, Статус:Разработен]; Категория:Containers)
 
(3 intermediate revisions by the same user not shown)
Line 24: Line 24:
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">
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
docker run -d -p 80:80 --name docker-tutorial docker101tutorial
</syntaxhighlight>''Then visit http://localhost/, where a nice tutorial should be displayed!''
</syntaxhighlight>
 
* <code>-d</code> - run the container in detached mode (in the background)
* <code>-p 80:80</code> - map port 80 of the host to port 80 in the container
* <code>docker/getting-started</code> - the image to use
 
''Then visit http://localhost/, where a nice tutorial should be displayed!''


== Now save and share your image ==
== Now save and share your image ==
Line 34: Line 40:
</syntaxhighlight>''Finally:'' [https://hub.docker.com/repositories/pa4080 See what you've saved on Hub].
</syntaxhighlight>''Finally:'' [https://hub.docker.com/repositories/pa4080 See what you've saved on Hub].


Note: If you want to <u>sign in from the Docker CLI</u>, you’ll need a personal access token. An access token is the only password accepted by the CLI <u>when you have 2FA enabled</u>.
Note: If you want to <u>sign in from the Docker CLI</u>, you’ll need a [https://hub.docker.com/settings/security personal access token]. An access token is the only password accepted by the CLI <u>when you have 2FA enabled</u>.


== Docker Desktop References ==
== Docker Desktop References ==
Line 48: Line 54:
{{devStage  
{{devStage  
  | Прндл  = Containers
  | Прндл  = Containers
  | Стадий = 4
  | Стадий = 6
  | Фаза  = Авторизиране
  | Фаза  = Утвърждаване
  | Статус = Разработен
  | Статус = Утвърден
  | ИдтПт  = Spas
  | ИдтПт  = Spas
  | РзбПт  = Spas
  | РзбПт  = Spas
  | АвтПт  = {{REVISIONUSER}}
  | АвтПт = Spas
| УтвПт = {{REVISIONUSER}}
  | ИдтДт  = 23.02.2023
  | ИдтДт  = 23.02.2023
  | РзбДт  = 23.02.2023
  | РзбДт  = 23.02.2023
  | АвтДт  = {{Today}}
  | АвтДт = 23.02.2023
| УтвДт = {{Today}}
  | ИдтРв  = [[Special:Permalink/32317|32317]]
  | ИдтРв  = [[Special:Permalink/32317|32317]]
  | РзбРв  = [[Special:Permalink/32322|32322]]
  | РзбРв  = [[Special:Permalink/32322|32322]]
  | АвтРв  = {{REVISIONID}}
  | АвтРв = [[Special:Permalink/32323|32323]]
| УтвРв = {{REVISIONID}}
}}
}}
</div>
</div>
</noinclude>
</noinclude>

Latest 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
  • -d – run the con­tain­er in de­tached mode (in the back­ground)
  • -p 80:80 – map port 80 of the host to port 80 in the con­tain­er
  • dock­er/get­ting-start­ed – the im­age to use

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.

Note: If you want to sign in from the Dock­er CLI, you’ll need a per­son­al ac­cess to­ken. An ac­cess to­ken is the on­ly pass­word ac­cept­ed by the CLI when you have 2FA en­abled.

Dock­er Desk­top Ref­er­ences