forked from ashishrpandey/devops
/
workingWithDocker
44 lines (29 loc) · 1.58 KB
/
workingWithDocker
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
Go throough https://docs.docker.com/get-started/part2/#share-your-image
## Create a repository on dockerhub [ashishrpandey/dockerrepo]
## Create tag
[ec2-user@ip-172-31-16-96 ~]$ docker tag hello-world:latest ashishrpandey/dockerrepo:new
[ec2-user@ip-172-31-16-96 ~]$ docker push --help
[ec2-user@ip-172-31-16-96 ~]$ docker login --username=ashishrpandey
Password:
Login Succeeded
[ec2-user@ip-172-31-16-96 ~]$ docker push ashishrpandey/dockerrepo:new
## Runt these commands to get more info about the docker
docker version
docker info
## All the fils related to containers and images are kept at /var/lib/docker/
**************Launch docker ***************
Launch a container running a PostgreSQL database and pass it the --net=my_bridge flag to connect it to your new network:
$ docker run -d --net=my_bridge --name container_name training/postgres
*********** Details of container ***********
$ docker inspect container_name
*********** Network Containers ************
$ docker network ls
$ docker run -itd --name=container_name ubuntu ## run container with name container_name
$ docker network inspect bridge ## inspect bridge network
### To get the ipaddress of the container:
$docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' container_name
You can remove a container from a network by disconnecting the container.
$ docker network disconnect bridge container_name
*********** Adding data volumes to Containers ************
This will create a new volume inside a container at /webapp.
$ docker run -d -P --name web -v /webapp training/webapp python app.py