-
Notifications
You must be signed in to change notification settings - Fork 0
/
DockerCommands
72 lines (42 loc) · 2.57 KB
/
DockerCommands
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
###########DOCKER COMMANDS####################3
https://medium.com/@pra4mesh/deploy-war-in-docker-tomcat-container-b52a3baea448
What is the different between docker run vs docker start :
Run: create a new container of an image, and execute the container. You can create N clones of the same image. The command is: docker run IMAGE_ID and not docker run CONTAINER_ID
Start: Launch a container previously stopped. For example, if you had stopped a database with the command docker stop CONTAINER_ID, you can relaunch the same container with the command docker start CONTAINER_ID, and the data and settings will be the same.
-----------------------------------------------------------------
List all images in your docker : docker image ls
--------------------------------------------------------------------
docker container create --publish 8082:8080 --name my-tomcat-
-------------------------------------------------------------------------
# to get inside your docker tomcat container directory...
docker container exec -it my-tomcat-container bash
----------------------------------------------------------
Containers Info : docker inspect <container id>
---------------------------------------------------------------------
# to get inside your docker tomcat container directory...
docker container exec -it my-tomcat-container bash
# it will list tomcat directory inside your docker as
# :/usr/local/tomcat# ls
# LICENSE NOTICE RELEASE-NOTES RUNNING.txt bin conf include lib # logs native-jni-lib temp webapps work
-----------------------------------------------------------------------------------------------------------------------------
FROM
The base image for building a new image. This command must be on top of the dockerfile.
MAINTAINER
Optional, it contains the name of the maintainer of the image.
RUN
Used to execute a command during the build process of the docker image.
ADD
Copy a file from the host machine to the new docker image. There is an option to use an URL for the file, docker will then download that file to the destination directory.
ENV
Define an environment variable.
CMD
Used for executing commands when we build a new container from the docker image.
ENTRYPOINT
Define the default command that will be executed when the container is running.
WORKDIR
This is directive for CMD command to be executed.
USER
Set the user or UID for the container created with the image.
VOLUME
Enable access/linked directory between the container and the host machine.
---------------------------------------------------------------------------------------------