Jump to content

Docker Tutorial: Difference between revisions

No edit summary
Line 48: Line 48:


=== Create Containers ===
=== Create Containers ===
==== Basic Creation ====


This is my go-to recipe for daily container creation:
This is my go-to recipe for daily container creation:


<syntaxhighlight lang=bash>
<syntaxhighlight lang=bash>
# Create the container
# Basic container creation
docker create -ti --name mycontainer ubuntu:18.04
docker create -ti --name mycontainer ubuntu:18.04
</syntaxhighlight>
==== Sharing Host Data With Volumes ====


Absolute paths refer to dirs or files in the host:
<syntaxhightlight lang=bash>
# Share dir: /home/mgruner (host) in /host (container)
# Share dir: /home/mgruner (host) in /host (container)
docker create -ti -v /home/mgruner/:/host ubuntu:18.04
docker create -ti -v /home/mgruner/:/host ubuntu:18.04
Line 68: Line 60:
# Share file: /home/mgruner/file.txt (host) in /host.txt (container)
# Share file: /home/mgruner/file.txt (host) in /host.txt (container)
docker create -ti -v /home/mgruner/file.txt:/host.txt ubuntu:18.04
docker create -ti -v /home/mgruner/file.txt:/host.txt ubuntu:18.04
</syntaxhighlight>


Paths with no slashes create persistent volumes
# Create a persistent volume for future use
<syntaxhightlight lang=bash>
# Create a persistent volume
docker create -ti -v myvolume:/host ubuntu:18.04
docker create -ti -v myvolume:/host ubuntu:18.04
</syntaxhighlight>
</syntaxhighlight>


[[Category:docker]][[Category:tutorial]]
[[Category:docker]][[Category:tutorial]]
Cookies help us deliver our services. By using our services, you agree to our use of cookies.