-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDocker Notes.txt
More file actions
55 lines (55 loc) · 5.36 KB
/
Docker Notes.txt
File metadata and controls
55 lines (55 loc) · 5.36 KB
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
cmds:
- docker build .: builds an image with the dockerfile and provided code in the current app folder to be used to spin up containers later
- docker run "container name": runs a container in attached mode, keeping you from inputting other commands until you stop the container
- docker start "container name": starts a container in detached mode, allowing you to input other commands, but if you need to input values in the cmd line, you can't do so
- docker ps: gets a list of all the running containers
- docker --help: shows a list of commands
- docker logs "container name": shows all the logs for a specific container
- docker logs -f "container name": shows all the logs for a specific container and follows them
- docker stop "container name": stops a container
- docker start -a "container name": starts a container in attached mode
- docker start -d "container name": starts a container in detached mode
- docker attach "container name": attaches you to a running container
- docker run -i "container name": Keep STDIN (Standard Input) even if not attached
- docker run -t "container name": allocate a pseudo-TTY, creates a terminal exposed by the container
- docker run -it "container name": combines the two above, allows for user input
- docker start -ai "container name": start version of the above
- docker rm "container name": remove container. Can only remove stopped containers.
- docker container prune: remove all containers.
- docker images: shows all downloaded images
- docker rmi "image id's separated by white space": removes all the images in the provided list of images
- docker run --m "image id": creates a container based on the image, allowing you to interact with the container (go to web app and play with it), but if it's ever stopped, the container is removed
- docker run -p 3000:80 -d --rm "image id": creates a detached container based on the provided image and is auto deleted if it's ever stopped
- docker image inspect "image id": take a look at the data, settings, and specs for the image
- docker cp "source" "container name": copies a file from the source into the identified container/folder of the container. source = (dummy/. - all, dummy/file.txt - file). container name = name:/path or folder
- Good to use for ini/config files.
- docker cp "container name" "source" : the above command but in reverse
- Allows you to copy a file from a container to your pc, so you can take a look at the source file within the container
- docker run -p 3000:80 -d --rm --name "desired name of container" "image id": allows you to assign a name to the container that will be created
- docker build -t "name":"tag" .: allows you to create an image with the provided name and tag, allows you to run a container on the named image (like an alias)
- name : tag = repository : tag
- repository - designates a specific group of images, like a namespace, Ex: node or python
- tag - specific/specialized image within a group of images, Ex: 14
- docker push "image_name": push docker image to docker hub
- docker pull "image_name": pull docker image from docker hub
- docker push/pull "host name":"image name": push and pull named images from an indicated docker repository
- !!! When pulling, docker will pull the latest image in your repository of the provided name.
- docker login: login to docker.combines
- !!!! When using docker run, if there's not an image on your machine with the specified tag, it will check your connected repository and pull down the latest image, but NOT CHECK FOR NEW UPDATES IF YOU ALREADY HAVE A LOCAL IMAGE
- docker volume ls: lists all docker created volumes
- docker run -d -p 3000:80 --rm --name feeback-app -v "name of volume":"path where files will be stored, ex: /app/feeback" feeback-node:volumes: Creates a container with a named volume and stores data in the specified path
- docker volume rm VOL_NAME: remove volumes
- volumes (anonymous and named) are managed by docker
- bind mounts are managed by you, great for persistent and editable data (by you), example: source code
- docker run -v "filepath of folder housing editable (source code) files":"where the files will be stored ex: /app"
- docker run -v "%cd%":/app: the same as above but where you're code is running from as a shortcut.
- docker run -d -p 3000:80 --name feedback-app -v feeback:/app/feedback -v "C:\VS Projects\Projects\Testing\Docker-Practical\data-volumes-01-starting-setup:/app" -v /app/node_modules feedback-node:volumes
- we had an error with the express module in the example. This was initially installed when running the RUN npm install
command at the creation of the container. Without "-v /app/node_modules", due to copying all files in the app
folder, the work docker did to set up json and npm install folders is overwritten. Adding
the "-v /app/node_modules" anonymous volume (cuz there's no specified name) saves that folder so it can be
used by the container/app when it's running.
- Why keep "COPY" in the dockerfile? We add the source code directory for development so we can quickly add/see changes in the project.
But once we go to production, if we don't have the "COPY" instruction in our dockerfile (we won't have the volume creation in the
production version once it's on a server), then it won't copy all the code for that project.
- .dockerignore - a file to add to your project so you can ignore certain folders when working with docker