Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

docker basic commands

docker –version
docker pull
docker run
docker ps
docker ps -a
docker exec
docker stop
docker kill
docker commit
docker login
docker push
docker images
docker rm
docker rmi
docker build

1. `docker ps`  # current containers
2. `docker run` # create and start the container
3. `docker create` # create container
4. `dokcer exec` # to run commnads in container for once
EX: command docker exec -it <container name> /bin/bash
5. `docker stop [container ID]` # terminate the container and save it's state by commit it 
6. `docker rm [container ID]` # remove container 
7. `docker inspect [container ID]` # Get more info about running container
___
7. `docker images` # list the images
8. `docker push` # push your image to docker repo
9. `docker pull` # download an image from docker repo
10. `docker commit` # create an image from container
11. `docker rmi` # remove image
___
12. `docker volume` # create a docker volume
13. `docker network` # create a docker network
14. `docker build` # build a new image from dockerfile
Comment

docker commands

Docker Commands v2.1 by BVieira
-forked from Basel Rabia

1. `docker ps`  # current containers
2. `docker run` # create and start the container
3. `docker create` # create container
4. `dokcer exec` # to run commnads in container for once
5. `docker stop [container ID]` # terminate the container and save it's state by commit it 
6. `docker rm [container ID]` # remove container 
7. `docker inspect [container ID]` # Get more info about running container
___
8. `docker images` # list the images
9. `docker push` # push your image to docker repo
10. `docker pull` # download an image from docker repo
11. `docker commit` # create an image from container
12. `docker rmi` # remove image
___
13. `docker volume` # create a docker volume
14. `docker network` # create a docker network
15. `docker build` # build a new image from dockerfile
___

16. Clean, stop, reset, purge and remove all traces of Docker in your environment

#Select all commands below and paste on terminal

```
docker stop $(docker ps -q)
docker rm -f $(docker ps -aq)
docker rmi $(docker images -q)
docker volume rm $(docker volume ls -q) 
docker network rm $(docker network ls -q)
docker volume prune  
docker system prune -a 
```
Comment

docker command

docker ps # current containers
docker run # create and start the container
docker create # create container
dokcer exec # to run commnads in container for once
docker volume # create a docker volume
docker network # create a docker network
docker rm # remove container 
docker images # list the images
docker rmi # remove image
docker build # build a new image from dockerfile
docker push # push your image to docker repo
docker pull # download an image from docker repo
docker commit # create an image from container
Comment

docker commands

$ docker images
  REPOSITORY   TAG        ID
  ubuntu       12.10      b750fe78269d
  me/myapp     latest     7b2431a8d968
Comment

docker commands

docker network create name_of_network
docker pull image_name
docker ps
docker ps -a
docker stop container_id or name
docker start container_id or name
docker run image_name
docker run -d image_name
docker run -d -p<machine_port>:<docker_port> -d --name=name_for_container image_name	
docker network ls
docker-compose -f mongo.yaml up 
docker build -t name_of_new_image:version path of docker file
	ex. docker build -t my_app:1.0.0 ./app
docker rmi image_id
docker rm container_id
docker exec -it container_id /bin/bash
docker exec -it container_id /bin/sh
docker ps -a | grep my-app (to list all the containers of a image)
docker run -d -e MONGO_DB_USERNAME=admin -e MONGO_DB_PWD=password my-app:1.1 (setting env variables at the time of container creation)
docker tag my-app:latest 159425601627.dkr.ecr.us-east-1.amazonaws.com/my-app:latest
docker push 159425601627.dkr.ecr.us-east-1.amazonaws.com/my-app:tag
docker logs [OPTIONS] container_id
	--details		Show extra details provided to logs
	--follow , -f		Follow log output
	--since		Show logs since timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g. 42m for 42 minutes)
	--tail , -n	all	Number of lines to show from the end of the logs
	--timestamps , -t		Show timestamps
	--until		Show logs before a timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g. 42m for 42 				minutes)
Comment

DOCKER commands

docker commit <id container> <name image> //создать образ
docker tag <name image> MandrykaValerii/<new name image> //что б можно было закинуть на Docker Hub
Comment

DOCKER CONTAINER commands

docker container attach <id контейнера или имя>
docker container prune -f//удалить все контенеры бес спроса
Comment

docker commands

LABEL "com.example.vendor"="ACME Incorporated"
LABEL com.example.label-with-value="foo"
Comment

docker commands

LABEL version="1.0"
Comment

docker commands

ENTRYPOINT exec top -b
Comment

docker commands

ENTRYPOINT ["executable", "param1", "param2"]
ENTRYPOINT command param1 param2
Comment

docker commands

EXPOSE 5900
CMD    ["bundle", "exec", "rails", "server"]
Comment

docker commands

ONBUILD RUN bundle install
# when used with another file
Comment

docker commands

ADD file.xyz /file.xyz
COPY --chown=user:group host_file.xyz /path/container_file.xyz
Comment

docker commands

VOLUME ["/data"]
# Specification for mount point
Comment

docker commands

WORKDIR /myapp
Comment

docker commands

RUN bundle install
Comment

docker commands

ENV APP_HOME /myapp
RUN mkdir $APP_HOME
Comment

docker commands

$ docker images -a   # also show intermediate
Comment

docker commands

$ docker ps
$ docker ps -a
$ docker kill $ID
Comment

docker commands

docker start [options] CONTAINER
  -a, --attach        # attach stdout/err
  -i, --interactive   # attach stdin

docker stop [options] CONTAINER
Comment

docker commands

$ docker exec app_web_1 tail logs/development.log
$ docker exec -t -i app_web_1 rails c
Comment

docker commands

docker exec [options] CONTAINER COMMAND
  -d, --detach        # run in background
  -i, --interactive   # stdin
  -t, --tty           # interactive
Comment

docker commands

$ docker create --name app_redis_1 
  --expose 6379 
  redis:3.0.2
Comment

docker commands

docker run [options] IMAGE
  # see `docker create` for options
Comment

docker commands

docker build [options] .
  -t "app/container_name"    # name
Comment

docker commands

LABEL description="This text illustrates 
that label-values can span multiple lines."
Comment

docker commands

docker rmi b750fe78269d
Comment

docker commands

docker cmds
Comment

docker commands

FROM ruby:2.2.2
Comment

PREVIOUS NEXT
Code Example
Shell :: add new file to context menu win 10 11 
Shell :: vim no space 
Shell :: shreck 
Shell :: fortios download linux 
Shell :: scripting sobre ficheros 
Shell :: * Connection #0 to host artifactory-us.cytiva.net left intact 
Shell :: awk select second field stored in a variable 
Shell :: ned red installation guide ubuntu 
Shell :: predate.sh linux error logging 
Shell :: zh-Hans publish 
Shell :: bokura no kiseki wikipedia 
Php :: if language wpml 
Php :: info.php 
Php :: install php8.1 
Php :: var_dump smarty 
Php :: get child theme path in wordpress 
Php :: fluid inline if 
Php :: laravel specified key was too long 
Php :: access to this resource on the server is denied laravel 
Php :: how to validate an email field using php 
Php :: laravel change post request before save 
Php :: laravel generate env 
Php :: ubuntu php uninstall 
Php :: Root composer.json requires php ^7.2.5 but your php version (8.0.6) does not satisfy that requirement. 
Php :: laravel inrandomorder 
Php :: str slug laravel 
Php :: php random string generator 
Php :: delete folder laravel 
Php :: date php 
Php :: get template name wordpress 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =