Skip to main content

Docker Commands

Docker Hub Registry

  • sudo docker login - To login into default docker registry https://hub.docker.com/
  • sudo docker login registryURL - To login into private registry
  • sudo docker push repoName/imageName:tag - Push image to registry in given repoName=respository name, as imageName with tag=ex. 1.0.0
  • sudo docker pull repoName/imageName:tag - Pulgl docker image
  • sudo docker tag existingRepoName/imageName:tag newRepoName/imageName:tag - Create new tagged image

Interacting with Container

  • sudo docker run -it imageName – -i means interactive, -t means provide terminal
  • sudo docker run -d imageName - -d means run in background mode
  • sudo docker cp [OPTIONS] CONTAINER:SRC_PATH DEST_PATH|-
  • sudo docker cp [OPTIONS] SRC_PATH|- CONTAINER:DEST_PATH - copy from host to container, viceversa possible
  • sudo docker exec containerName/ID command - run a command in existing container, giving output on localhost terminal
  • sudo docker exec -it containerName/ID /bin/bash - use to go inside container
  • sudo docker ps – list running containers
  • sudo docker ps -a – list all containers
  • sudo docker start containerName/ID – start the stopped container
  • sudo docker stop containerName/ID – stop the running container
  • sudo docker rm containerName/ID – remove the container process
  • sudo docker rm $(sudo docker ps -aq) – remove all exited container process
  • sudo docker inspect containerName/ID – show information about container in json format
  • sudo docker logs containerName/ID – Fetch the logs from container, argument -f will show live logs
  • sudo docker stats containerName/ID – show live usage of resources by container (can be run with multiple container in the same command line)
  • sudo docker top containerName/ID – show running process in container

Docker Image Management Commands

  • sudo docker build -t repoName/imageName . – Create docker image
  • sudo docker images – list the image
  • sudo docker history imageName – show the image history
  • sudo docker inspect imageName – show docker image information in json format
  • sudo docker tag imageName1 imageName2 – tag the image
  • sudo docker rmi imageName – remove the image
  • sudo docker pull repoName/imageName – pull the docker image from registry
  • sudo docker push repoName/imagename – push the docker image to registry
  • sudo docker save imageName -o imageName.tar.gz – save the image as tar ball
  • sudo docker load --input tarFileName.tar.gz – load the image from tar ball as docker image

Other Commands

  • sudo docker info – display the system-wide information about docker

Comments

Popular posts from this blog

How to skip resources, compiler, surfire, install plugin in maven's default build process

When we want to use maven command line to upload zip type artifact to artifact repository then we don't want resources, compiler, surefire, install phases in maven process, only assembly would be enough. To skip particular phases go to each plugin's original website phase according to latest running plugin version download the same to our own project refer the skip phase configuration of particular phase, either it can be done command line or as part of the build-plugin-configuration. Example using POM.xml file <project> [...] <build> <plugins> <plugin> <groupId...

How to clone Github repository using SSH

Run ssh-keygen Upload ssh public key to github account curl -u "gitUsername:password" --data '{"title":"keyName","key":"'"$(cat ~/.ssh/id_rsa.pub)"'"}' https://api.github.com/user/keys Sample output of ssh public key upload command { "id": 1234567890, "key": "ssh-rsa aaaaaaaaaaaaaaaaaaaa/dddd/+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "url": "https://api.github.com/user/keys/123456...

Install AWS CLI on Ubuntu localhost using Ansible Playbook

Install AWS CLI on Ubuntu localhost using Ansible Playbook --- - hosts: localhost tasks: - name: Installing Unzip package package: name: unzip state: present when: ansible_facts['os_family'] == "Debian" become: true - name: Create awscli directory in home directory file: path: ~/awscli state: directory mode: '0755' - name: Download bundled installer zip file get_url: url: https://s3.amazonaws.com/aws-cli/awscli-bundle.zip dest: ~/awscli/awscli-bundle.zip - name: Extract zip file unarchive: src: ~/awscli/awscli-bundle.zip dest: ~/awscli - name: Run install command shell: /home/ubuntu/awscli/awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws become: true Same script is also avail...