playground:playground
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
playground:playground [2019-09-05 02:34] – pushyamikaveti | playground:playground [2024-04-21 06:37] (current) – old revision restored (2024-04-18 09:14) 108.35.80.215 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ===== Tutorial on Using Docker ===== | + | == Basic text formatting |
+ | You can format the page using Wikitext special characters. | ||
- | ==== What is Docker? ==== | + | {| border=" |
- | Docker is a platform that helps with easy deployment of applications inside a container. Containers are very similar to virtual machines but are getting more popular due to theor flexibility and ease of use. Some key differences | + | !width=" |
- | === Image vs container === | + | !width=" |
- | A container is created | + | | |
+ | | | ||
+ | You can '' | ||
+ | apostrophes on '' | ||
- | A container is a runtime instance of an image--what | + | 3 apostrophes will ''' |
- | === Container vs virtual machine === | ||
- | A container runs natively on Linux and shares the kernel of the host machine with other containers. It runs a discrete process, taking no more memory than any other executable, making it lightweight. | ||
- | By contrast, a virtual machine (VM) runs a full-blown “guest” operating system with virtual access to host resources through a hypervisor. In general, VMs provide an environment with more resources than most applications need. | + | 5 apostrophes will ''''' |
+ | the text. | ||
- | {{: | + | (Using 4 apostrophes doesn' |
+ | special -- <br /> 3 of them ''' | ||
+ | usual; the others are '''' | ||
+ | around the text.) | ||
- | ==== Preparing Docker Environment ==== | + | | |
+ | You can '' | ||
+ | apostrophes on '' | ||
- | === Installation === | + | 3 apostrophes will ''' |
- | Install Docker-CE community edition by following | + | 5 apostrophes will ''''' |
- | https:// | + | the text. |
- | There are three ways to install docker | + | (Using 4 apostrophes doesn' |
- | 1. Using docker repositories via "sudo apt" | + | special -- <br /> 3 of them ''' |
- | 2. Manual installation using .deb file and update when needed | + | usual; the others |
- | 3. Using convenience scripts - Mostly for dev/test environments needing automation | + | around the text.) |
+ | </ | ||
+ | |- | ||
+ | | | ||
+ | A single newline | ||
+ | generally has no effect on the layout. | ||
+ | These can be used to separate | ||
+ | sentences within a paragraph. | ||
+ | Some editors find that this aids editing | ||
+ | and improves the '' | ||
+ | (used internally to compare | ||
+ | different versions of a page). | ||
- | We go with first option " | + | But an empty line |
- | Do not forget to go through Post installation instructions here : https:// | + | starts a new paragraph. |
- | This is useful to use docker without having to specify " | + | |
+ | When used in a list, a newline '' | ||
+ | |< | ||
+ | A single newline | ||
+ | generally has no effect on the layout. | ||
+ | These can be used to separate | ||
+ | sentences within a paragraph. | ||
+ | Some editors find that this aids editing | ||
+ | and improves the '' | ||
+ | (used internally to compare | ||
+ | different versions of a page). | ||
- | === Test Installation === | + | But an empty line |
+ | starts a new paragraph. | ||
- | Test for successful installation of Docker by executing following commands | + | When used in a list, a newline '' |
+ | affect the layout ([[# | ||
+ | </ | ||
+ | | | ||
+ | | | ||
+ | You can break lines< | ||
+ | without a new paragraph.< | ||
+ | Please use this sparingly. | ||
- | Docker --version | + | Please do not start a link or '' |
- | This should give an output as shown below | + | |< |
+ | You can break lines< | ||
+ | without a new paragraph.< | ||
+ | Please use this sparingly. | ||
- | Docker version 19.03.1, build 74b1e89e8a | + | Please do not start a link or |
- | + | '' | |
- | Now execute | + | and end on the next. |
- | + | </syntaxhighlight> | |
- | Docker run hello-world | + | |- |
- | + | ||
- | This command downloads and runs a test image. This should produce the following output | + | |
- | + | ||
- | latest: Pulling from library/ | + | |
- | 1b930d010525: | + | |
- | Digest: sha256: | + | |
- | Status: Downloaded newer image for hello-world: | + | |
- | + | ||
- | Hello from Docker! | + | |
- | This message shows that your installation appears to be working correctly. | + | |
- | + | ||
- | To generate this message, Docker took the following steps: | + | |
- | 1. The Docker client contacted the Docker daemon. | + | |
- | 2. The Docker daemon pulled the " | + | |
- | 3. The Docker daemon created a new container from that image which runs the | + | |
- | executable that produces the output you are currently reading. | + | |
- | 4. The Docker daemon streamed that output to the Docker client, which sent it | + | |
- | to your terminal. | + | |
- | + | ||
- | You can also run which gives more information | + | |
- | docker info | + | |
- | + | ||
- | Containers: 0 | + | |
- | Running: 0 | + | |
- | Paused: 0 | + | |
- | Stopped: 0 | + | |
- | Images: 0 | + | |
- | Server Version: 17.12.0-ce | + | |
- | Storage Driver: overlay2 | + | |
- | ... | + | |
- | + | ||
- | === NVIDIA Docker === | + | |
- | + | ||
- | This is useful to use docker image with nvidia runtime. we can now create GPU accelerated containers and run applications inside. This avoids the need to install the CUDA/GPU driver inside the containers and have it match the host kernel module. Instead, drivers are on the host and the containers don't need them.https:// | + | |
- | + | ||
- | Note : The latest version is nvidia-container-toolkit. You can install that and see its usage from the official github page here https:// | + | |
- | But, at the time of making this document [[https:// | + | |
- | + | ||
- | A container can be run using --runtime=nvidia option as follows | + | |
- | docker run --runtime=nvidia nvidia/ | + | |
- | + | ||
- | In the above command we are running an image named " | + | |
- | + | ||
- | ==== Working With Docker ==== | + | |
- | + | ||
- | === Working with an existing docker image === | + | |
- | + | ||
- | == What are Docker images and where can I get them from? == | + | |
- | Docker containers are created from docker images. By default docker images are pulled from Docker Hub. You can think of it as something similar to github where code lives. In DockerHub docker images , their version history with tags live. DockerHub is managed my Docker company. Anybody can build and host their Docker images | + | |
- | + | ||
- | For example in the previous section " | + | |
- | docker run --runtime=nvidia nvidia/cuda: | + | |
- | + | ||
- | we pulled an image from [[https:// | + | |
- | + | ||
- | == Search for Images == | + | |
- | We can check for available images on docker hub using %% search %% subcommand. FOr example | + | |
- | docker search ubuntu | + | |
- | This will crawl Docker Hub and gives a listing of all images that match with search string Ubuntu. | + | |
- | + | ||
- | == docker run == | + | |
- | docker run ubuntu | + | |
- | + | ||
- | Unable to find image ' | + | |
- | latest: Pulling from library/ | + | |
- | 35c102085707: | + | |
- | 251f5509d51d: | + | |
- | 8e829fe70a46: | + | |
- | 6001e1789921: | + | |
- | Digest: sha256: | + | |
- | Status: Downloaded newer image for ubuntu: | + | |
- | When this command is executed docker initially looks for the image named ubuntu locally. when it doesnt find the image, it pulls from docker hub. Whenever we do not specify a tag " | + | |
- | docker run -it ubuntu | + | |
- | + | ||
- | root@cf3f32ce0c33:/# | + | |
- | + | ||
- | using -it option lets us access the running image via interactive terminal as shown above. Here " | + | |
- | + | ||
- | Containers are designed to mainly run an application. Hence, docker run is meant to run a command and then exit the container. we can just start and keep the container in active by using -it option with docker run command. | + | |
- | + | ||
- | == docker pull == | + | |
- | + | ||
- | docker pull ubuntu | + | |
- | + | ||
- | This command just downloads the image. The default location where all the images are stored is / | + | |
- | + | ||
- | === Docker Cheat Sheet === | + | |
- | + | ||
- | == docker start/stop == | + | |
- | start a stopped container using %% docker start < | + | |
- | + | ||
- | == List images == | + | |
- | docker images | + | |
- | + | ||
- | == List containers == | + | |
- | %% docker ps %% lists only active containers | + | |
- | %% docker ps -a %% Lists all the containers | + | |
- | CONTAINER ID IMAGE | + | |
- | PORTS | + | |
- | cf3f32ce0c33 | + | |
- | (0) 2 minutes ago | + | |
- | b0c54578020b | + | |
- | (0) 7 minutes ago | + | |
- | 6cc5fda09e89 | + | |
- | (0) 2 hours ago | + | |
- | 71a3b955c10a | + | |
- | (0) 4 weeks ago | + | |
- | b8add4a38631 | + | |
- | (0) 4 weeks ago | + | |
- | + | ||
- | + | ||
- | === Setup a Docker Image === | + | |
- | + | ||
- | ==== Docker with GUI ==== | + | |
- | + | ||
- | ==== Docker Compose ==== | + | |
+ | |You should " | ||
+ | <div class=" | ||
+ | * Three tildes gives your signature: [[User: | ||
+ | * Four tildes give your signature plus date/time: [[User: | ||
+ | * Five tildes gives the date/time alone: 07:46, 27 November 2005 (UTC) <br/> | ||
+ | </ | ||
+ | |< | ||
+ | You should " | ||
+ | on talk pages: | ||
+ | * Three tildes gives your | ||
+ | | ||
+ | * Four tildes give your | ||
+ | | ||
+ | * Five tildes gives the | ||
+ | | ||
+ | </ | ||
+ | |} | ||
playground/playground.1567643646.txt.gz · Last modified: 2019-09-05 02:34 by pushyamikaveti