-
Notifications
You must be signed in to change notification settings - Fork 1
/
ContainerBasics.ps1
95 lines (66 loc) · 1.89 KB
/
ContainerBasics.ps1
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#To see docker verison
docker verison
#detailed docker information
docker info
#to see local docker images
docker images
docker images ls
#show images values without trunc (ex. see the full image id)
docker images --no-trunc
#search online images from dockerhub
docker search ubuntu
#download docker image
docker pull ubuntu
#download specific image
docker pull ubuntu:19.10
#create and run container from image
# 'd' for deattached mode 'it' for interactive mode
docker container run ubuntu
docker run -d -p 8080:80 --name ubuntu1 ubuntu
docker run it --name temp ubuntu
#attach to existing and running container
docker attach <containerid>
#to see container logs
docker logs ubuntu1
#see running containers
docker ps
docker container ls
#see all containers
docker ps -a
docker container ls -a
#to execute command on container (executing sh command)
docker container exec -it devcontainer sh
#to see docker volumes
dokcer volume ls
#to create docker volumes
docker volume create devvolume
#to inspect docker volumes
docker volume inspect devvolume
#to attach volume to container
docker container run -d --name devcontainer --mount source=devvolume,target=/app nginx
docker container run -d --name devcontainer2 -v devvolume:/app nginx
#to see volumes on linux
sudo ls /var/lib/docker/volumes
sudo ls /var/lib/docker/volumes/devvolume
#stop docker container
docker stop ubuntu1
#delete container
docker rm ubuntu1
docker container rm ubuntu1
#delete all containers
Docker container rm -f $(docker ps -aq)
#delete container image
docker rmi ubuntu
docker image rm ubuntu
#inspect docker image
docker inspect ubuntu
#see container ip, ports etc.
docker inspect containername
#to see docker image history
docker history ubuntu
#to login registry
docker login
#to tag docker images
docker tag ubuntu oyuksektepeli/ubuntucustom:v1
#to push images to repository
docker push oyuksektepeli/ubuntucustom:v1