Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
O orientation
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 9
    • Issues 9
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge requests 36
    • Merge requests 36
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Container Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Newbies
  • orientation
  • Wiki
  • dockerBasics

dockerBasics · Changes

Page history
Update dockerBasics authored Jun 04, 2020 by Sneha's avatar Sneha
Hide whitespace changes
Inline Side-by-side
Showing with 20 additions and 20 deletions
+20 -20
  • dockerBasics.md dockerBasics.md +20 -20
  • No files found.
dockerBasics.md
View page @ 4239b002
......@@ -53,12 +53,12 @@ Docker Hub is the official online repository where you could find all the Docker
# Docker Installation
1. Uninstall the older version of docker if is already installed
```
```sh
$ sudo apt-get remove docker docker-engine docker.io containerd runc
```
2. Installing CE (Community Docker Engine)
```
```sh
$ sudo apt-get update
$ sudo apt-get install \
apt-transport-https \
......@@ -87,13 +87,13 @@ $ sudo docker run hello-world
## docker create
* This command allows us to create a new container.
* Syntax
```
```sh
docker create [options] IMAGE [commands] [arguments]
```
`Note: Anything enclosed within the square brackets is optional.`
e.g.
```
```sh
$ docker create fedora
02576e880a2ccbb4ce5c51032ea3b3bb8316e5b626861fc87d28627c810af03
......@@ -106,7 +106,7 @@ Refer given link for more details.
## docker ps
* The docker ps command allows us to view all the containers that are running on the Docker Host.
```
```sh
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
......@@ -130,15 +130,15 @@ docker ps output details
## docker start
* This command starts any stopped container(s).
* Syntax
```
```sh
$ docker start [options] CONTAINER ID/NAME [CONTAINER ID/NAME…]
```
* Example
```
```sh
$ docker start 30986
```
In the above example, Docker starts the container beginning with the container ID 30986.
```
```sh
$ docker start sneha
```
Whereas in this example, Docker starts the container named sneha.
......@@ -146,15 +146,15 @@ Whereas in this example, Docker starts the container named sneha.
## docker stop
* This command stops any running container(s).
* Syntax
```
```sh
$ docker stop [options] CONTAINER ID/NAME [CONTAINER ID/NAME…]
```
* Example
```
```sh
$ docker stop 30986
```
In the above example, Docker will stop the container beginning with the container ID 30986.
```
```sh
$ docker stop sneha
```
Whereas in this example, Docker will stop the container named sneha.
......@@ -173,13 +173,13 @@ Whereas in this example, Docker will stop the container named sneha.
0 directories, 2 files
```
2. Edit main.py
```
```sh
#!/usr/bin/env python3
print("Docker is magic!")
```
3. Edit Dockerfile
```
```sh
# A dockerfile must always start by importing the base image.
# We use the keyword 'FROM' to do that.
# In our example, we want import the python image.
......@@ -200,14 +200,14 @@ CMD [ "python", "./main.py" ]
```
4. Create the Docker image
* Once your code is ready and the Dockerfile is written, all you have to do is create your image to contain your application.
```
```sh
$ docker build -t python-test .
```
* The ’-t’ option allows you to define the name of your image. In our case we have chosen ’python-test’ but you can put what you want.
5. Run the Docker image
* Once the image is created, your code is ready to be launched.
```
```sh
$ docker run python-test
```
* You need to put the name of your image after `docker run`.
......@@ -224,17 +224,17 @@ Click on Create Repository button, put the name and enter.
![repo2](extras/repo2.png)
3. Now we will tag the image and push it to dockerhub repository which we just created.
```
```sh
# Run this commend to list docker images
$ docker images
```
which will give you this list
```
```sh
REPOSITORY TAG IMAGE ID CREATED SIZE
snehabhapkar/python-test latest c7857f97ebbd 2 hours ago 933MB
```
Image ID is used to tag the image. So lets tag syntax is `docker tag <image-id of docker-whale> <your dockerhub username>/docker-whale:latest`
```
```sh
$ docker tag c7857f97ebbd snehabhapkar/python-test:latest
# Push image to the repository
$ docker push snehabhapkar/python-test
......@@ -243,12 +243,12 @@ $ docker push snehabhapkar/python-test
## Pull and run the image
1. Let’s remove all versions of python-test image on our local system. Use Image ID to do that.
```
```sh
$ docker rmi -f c7857f97ebbd
```
2. Lets run the image, if it doesn't find it on local machine, it fetched it from dockerhub and run.
```
```sh
$ docker run snehabhapkar/python-test
```
This will give the desired output.
......
Clone repository
  • 20hrLearning
  • Code Workspace
  • Culture
  • FAQ
  • Home
  • Installing Required Tools
  • codeworkspace
  • codingStyle
  • coding_style_c_cpp
  • coding_style_python
  • dockerBasics
  • gitBasics
  • gitlabBasics
  • install tools ubuntu 16.04
  • install tools windows
View All Pages