0% found this document useful (0 votes)
55 views

Docker Documentation: Docker Is A Tool Designed To Make It Easier To Create, Deploy, and Run Applications by Using

Docker allows developers to package applications and dependencies into containers that can be deployed across systems. This document provides instructions for installing Docker on Linux and running a simple "hello world" application in a Docker container. It demonstrates building a Docker image from a container using either commit or a Dockerfile, and describes how to copy files between the local system and container and save container logs to a file.

Uploaded by

Arshiya Banu
Copyright
© © All Rights Reserved
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views

Docker Documentation: Docker Is A Tool Designed To Make It Easier To Create, Deploy, and Run Applications by Using

Docker allows developers to package applications and dependencies into containers that can be deployed across systems. This document provides instructions for installing Docker on Linux and running a simple "hello world" application in a Docker container. It demonstrates building a Docker image from a container using either commit or a Dockerfile, and describes how to copy files between the local system and container and save container logs to a file.

Uploaded by

Arshiya Banu
Copyright
© © All Rights Reserved
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Docker Documentation

Docker is a tool designed to make it easier to create, deploy, and run applications by using
containers. Containers allow a developer to package up an application with all of the parts it needs,
such as libraries and other dependencies, and ship it all out as one package.

Installing Docker on Linux

$ curl https://get.docker.com > /tmp/install.sh


$ cat /tmp/install.sh
...
$ chmod +x /tmp/install.sh
$ /tmp/install.sh

Write a simple program in the main terminal and create the .bin file and excecute it.

Running Your First Image

$ sudo docker run --name <containername> -it ubuntu


$ sudo docker run --name sample -it ubuntu

after using this command we enter into the interactive terminal

root@0cbebaa72623:/#

To copy the file or program from main terminal use the following command

$sudo docker cp <programname> <root_id>:/dir/


$sudo docker cp hello_world.c 0cbebaa72623:/home/

Command to List containers and get the container id


$ sudo docker ps -a

We can build an image using two methods


1. By commiting

Command to commit
$sudo docker commit <container id> repository:tagname

To run the image get image id using the command


$sudo docker images
$sudo docker run -it <image id>
We enter into the interactive terminal and now we can execute the program
2.By creating a Dockerfile

$ vi Dockerfile
script
FROM repository:tagname
CMD <path ./home/ >

save the docker file and command to build it


$sudo docker build -t repository:tagname .
$sudo docker images
$sudo docker run -it <image id>

To save docker logs to a file

Edit the Dockerfile


$ vi Dockerfile

NOTE: We need to create new repository, tagname and container name to


save the logs
build the Dockerfile
$ sudo docker build -t repository:tagname .

run the Dockerfile


$ sudo docker run --name <container name> -it <image id>

save docker log to file


$ sudo docker logs <containername>

$ sudo docker logs <container name> > <file name>

Now to see the output open the file


$ vi <filename>

You might also like