Docker Desktop Build Container Tutorial: Difference between revisions

From WikiMLT
m (Стадий: 6 [Фаза:Утвърждаване, Статус:Утвърден]; Категория:Containers)
Line 34: Line 34:
</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 ==

Revision as of 12:46, 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.

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