DokuWiki

It's better when it's simple

User Tools

Site Tools


playground:playground

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
playground:playground [2019-09-05 02:34] pushyamikavetiplayground: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="1" cellpadding="2" cellspacing="0" 
-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="1000"|What it looks like 
-=== Image vs container === +!width="500"|What you type 
-A container is created by running an image. An image is an executable package that includes everything needed to run an application--the code, a runtime, libraries, environment variables, and configuration files.+| 
 +| 
 +You can ''italicize'' text by putting 2  
 +apostrophes on ''each'' side
  
-A container is a runtime instance of an image--what the image becomes in memory when executed (that is, an image with state, or a user process). You can see a list of your running containers with the command, docker ps, just as you would in Linux.+3 apostrophes will '''bold''' the text
  
-=== 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 '''''bold and italicize'''''  
 +the text.
  
-{{:container_vs_virtualmachine.png?250|}}    \ \ \ \ \ \     {{:vm.png?250|}}+(Using 4 apostrophes doesn't do anything 
 +special -- <br /> 3 of them '''bold''' the text as 
 +usual; the others are ''''just'''' apostrophes  
 +around the text.)
  
-==== Preparing Docker Environment ====+
 +You can ''italicize'' text by putting 2  
 +apostrophes on ''each'' side. 
  
-=== Installation ===+3 apostrophes will '''bold''' the text. 
  
-Install Docker-CE community edition by following the instructions here  +5 apostrophes will '''''bold and italicize'''''  
-https://docs.docker.com/install/linux/docker-ce/ubuntu/+the text.
  
-There are three ways to install docker +(Using 4 apostrophes doesn't do anything 
-1Using docker repositories via "sudo apt"  +special -- <br /> 3 of them '''bold''' the text as 
-2Manual installation using .deb file and update when needed +usual; the others are ''''just'''' apostrophes  
-3Using convenience scripts - Mostly for dev/test environments needing automation+around the text.) 
 +</syntaxhighlight> 
 +|- 
 +
 +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 ''diff'' function 
 +(used internally to compare 
 +different versions of a page).
  
-We go with first option "INSTALLING USING REPOSITORIES". Follow this section in the link above. +But an empty line 
-Do not forget to go through Post installation instructions here : https://docs.docker.com/install/linux/linux-postinstall/ +starts a new paragraph.
-This is useful to use docker without having to specify "sudo".+
  
 +When used in a list, a newline ''does'' affect the layout ([[#lists|see below]]).
 +|<syntaxhighlight lang=wikitext>
 +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 ''diff'' function
 +(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 ''does'' 
 +affect the layout ([[#lists|see below]]). 
 +</syntaxhighlight> 
 +
 +
 +You can break lines<br/> 
 +without a new paragraph.<br/> 
 +Please use this sparingly.
  
-  Docker --version  +Please do not start a link or ''italics'' or '''bold''' text on one line and end on the next. 
-This should give an output as shown below+|<syntaxhighlight lang=wikitext> 
 +You can break lines<br/> 
 +without a new paragraph.<br/> 
 +Please use this sparingly.
  
-  Docker version 19.03.1, build 74b1e89e8a  +Please do not start link or 
- +''italics'' or '''bold''' text on one line 
-Now execute  +and end on the next
- +</syntaxhighlight> 
-  Docker run hello-world  +|-
- +
-This command downloads and runs test image. This should produce the following output +
- +
-  latest: Pulling from library/hello-world +
-  1b930d010525: Pull complete  +
-  Digest: sha256:451ce787d12369c5df2a32c85e5a03d52cbcef6eb3586dd03075f3034f10adcd +
-  Status: Downloaded newer image for hello-world:latest +
- +
-  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 "hello-world" image from the Docker Hub.(amd64)  +
-    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://www.nvidia.com/object/docker-container.html +
- +
-Note : The latest version is nvidia-container-toolkit. You can install that and see its usage from the official github page here https://github.com/NVIDIA/nvidia-docker +
-But, at the time of making this document [[https://github.com/NVIDIA/nvidia-docker| nvidia-docker2 ]] was being used. For now nvidia-docker2 can be upgraded as mentioned on the [[https://github.com/NVIDIA/nvidia-docker |github page]] and supports all the cli options as nvidia-container-toolkit. +
- +
-A container can be run using --runtime=nvidia option as follows +
-  docker run --runtime=nvidia nvidia/cuda:9.0-cudnn7-devel nvidia-smi +
-   +
-In the above command we are running an image named "cuda:9.0-cudnn7-devel" from nvidia repository and then executes the command "nvidia-smi" inside it. If the nvidia-docker installation is correct it should produce the output showing the nvidia-driver details from inside the docker container. +
- +
-==== 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 on Docker Hub, So most of the common applications and Linux distributions you’ll need to run Docker containers have images that are hosted on Docker Hub+
- +
-For example in the previous section "NVIDIA DOCKER" we ran  +
-  docker run --runtime=nvidia nvidia/cuda:9.0-cudnn7-devel nvidia-smi +
- +
-we pulled an image from [[https://hub.docker.com/r/nvidia/cuda nvidia/cuda]] repository with tag %% 9.0-cudnn7-devel %% . +
- +
-== 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 'ubuntu:latest' locally +
-  latest: Pulling from library/ubuntu +
-  35c102085707: Pull complete  +
-  251f5509d51d: Pull complete  +
-  8e829fe70a46: Pull complete  +
-  6001e1789921: Pull complete  +
-  Digest: sha256:d1d454df0f579c6be4d8161d227462d69e163a8ff9d20a847533989cf0c94d90 +
-  Status: Downloaded newer image for ubuntu:latest +
-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 "latest" is pulled by default. +
-  docker run -it ubuntu +
-  +
-  root@cf3f32ce0c33:/#  +
-   +
-using -it option lets us access the running image via interactive terminal as shown above. Here "cf3f32ce0c33" is the container ID and by default the user is root. +
- +
-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 /var/lib/docker +
-  +
-=== Docker Cheat Sheet === +
- +
-== docker start/stop == +
-start a stopped container using %% docker start <containerID>. Similarly to stop a container %% docker stop <ContainerID> %% +
- +
-== List images == +
-  docker images +
-   +
-== List containers == +
- %% docker ps %% lists only active containers  +
- %% docker ps -a %% Lists all the containers +
-  CONTAINER ID        IMAGE                                 COMMAND             CREATED             STATUS                      +
-  PORTS               NAMES +
-  cf3f32ce0c33        ubuntu                                "/bin/bash"         4 minutes ago       Exited  +
-  (0) 2 minutes ago                       kind_matsumoto +
-  b0c54578020b        ubuntu                                "/bin/bash"         7 minutes ago       Exited  +
-  (0) 7 minutes ago                       hopeful_sanderson +
-  6cc5fda09e89        hello-world                           "/hello"            2 hours ago         Exited  +
-  (0) 2 hours ago                         pensive_shaw +
-  71a3b955c10a        nvidia/cudagl:9.0-devel-ubuntu16.04   "/bin/bash"         4 weeks ago         Exited  +
-  (0) 4 weeks ago                         sweet_greider +
-  b8add4a38631        nvidia/cuda:9.0-devel                 "/bin/bash"         4 weeks ago         Exited  +
-  (0) 4 weeks ago                         sweet_wu +
- +
- +
-=== Setup a Docker Image === +
- +
-==== Docker with GUI ==== +
- +
-==== Docker Compose ====+
  
 +|You should "sign" your comments on talk pages: <br/>
 +<div class="mw-notalk">
 +* Three tildes gives your signature: [[User:Example|Example]] <br/>
 +* Four tildes give your signature plus date/time: [[User:Example|Example]] 07:46, 27 November 2005 (UTC) <br/>
 +* Five tildes gives the date/time alone: 07:46, 27 November 2005 (UTC) <br/>
 +</div>
 +|<syntaxhighlight lang=wikitext>
 + You should "sign" your comments 
 + on talk pages:
 + * Three tildes gives your
 + signature: ~~~
 + * Four tildes give your 
 + signature plus date/time: ~~~~
 + * Five tildes gives the 
 + date/time alone: ~~~~~
 +</syntaxhighlight>
 +|}
  
playground/playground.1567643646.txt.gz · Last modified: 2019-09-05 02:34 by pushyamikaveti

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki