Docker Desktop Build Container Tutorial: Difference between revisions
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 | ||
| Стадий = | | Стадий = 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 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.
docker run --name repo alpine/git \
clone https://github.com/docker/getting-started.git
docker cp repo:/git/getting-started/ .
You can also type the command directly in a command line interface.
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.
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 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.
docker run -d -p 80:80 --name docker-tutorial docker101tutorial
-d
– run the container in detached mode (in the background)-p 80:80
– map port 80 of the host to port 80 in the containerdocker/getting-started
– the image to use
Then visit http://localhost/, where a nice tutorial should be displayed!
You must be signed in to Docker Hub to share your image. 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.
dockdocker tag docker101tutorial pa4080/docker101tutorial
docker push pa4080/docker101tutorial
Finally: See what you've saved on Hub.
Note: If you want to sign in from the Docker CLI, you’ll need a personal access token. An access token is the only password accepted by the CLI when you have 2FA enabled.
Docker Desktop References
- Docker Docs: Install Docker Desktop on Mac
- Docker Docs: Back up and restore data
- Docker Docs: Get started
- See also: hub.docker.com