Posts

Showing posts with the label Recent Posts

How To Pull A Docker Image And Run A Container

This quick tutorial is going to cover how to pull a Docker image and run a container.1. List or Search For a Docker ImageBefore we can pull a Docker image and run a container, we should know its name first. And to do that, we can go to the Docker hub or Docker store to search for any name.The alternative way is to use the docker search command to list or search for a Docker image. Let’s see the following example which we search for an Ubuntu docker from the default public registry: [vagrant@localhost ~]$ docker search ubuntu NAME DESCRIPTION STARS OFFICIAL AUTOMATED ubuntu Ubuntu is a Debian-based Linux operating s... 5710 [OK] rastasheep/ubuntu-sshd Dockerized SSH service, built on top of of... 77 [OK] ubuntu-upstart Upstart is an event-based replacement for ... 71 [OK] consol/ubuntu-xfce-vnc Ubuntu container with "headless" VNC sessi... 45 …

Attach and Detach from Docker Container

1. OverviewThis tutorial is going to cover how to attach and detach from Docker container. It could be necessary either to view its ongoing output or to control it interactively and then detach from it when we’re done.2. Attach to a Running Docker ContainerTo attach to a running Docker container, we can use the docker attach command which has the syntax as the following: docker attach [OPTIONS] CONTAINER Some command’s options:Name, shorthandDefaultDescription–detach-keysTableOverride the key sequence for detaching a container–no-stdinfalseDo not attach STDIN–sig-proxytrueProxy all received signals to the process Example:We can attach to the same contained process multiple times simultaneously, screen sharing style, or quickly view the progress of our detached process.Let’s say we have an opensuse docker and start it in background as the following: docker run -d --name attachdemo opensuse /usr/bin/top -bTo attach to the above running container, we can issue the following command: [vagr…

Using New Composed Annotations for @RequestMapping in Spring Framework

1. OverviewThis article is going to cover about using new composed annotations for @RequestMapping, the annotation for mapping web requests onto specific handler classes and/or handler methods in Spring Framework. Those annotations, which include @GetMapping, @PostMapping, @PutMapping, @DeleteMapping and @PatchMapping, have been introduced in the Spring Framework 4.3.2. New Composed Annotations for @RequestMappingLet’s see how the new composed annotations act as shortcuts for @RequestMapping annotation in the following situations:Composed AnnotationsShortcut For@GetMapping@RequestMapping(method = RequestMethod.GET)@PostMapping@RequestMapping(method = RequestMethod.POST)@PutMapping@RequestMapping(method = RequestMethod.PUT)@DeleteMapping@RequestMapping(method = RequestMethod.DELETE)@PatchMapping@RequestMapping(method = RequestMethod.PATCH) 2.1. @GetMapping Annotation@GetMapping is a composed annotation that acts as a shortcut for @RequestMapping(method = RequestMethod.GET)2.2. @PostMapp…

How To Remove Docker Images, Containers, Volumes, and Networks

This tutorial is going to cover how to remove Docker images, containers, volumes, and networks.1. Remove Docker Images1.1. List All Docker ImagesBefore removing a Docker image, we have to know its name or id first. And we can use the docker images command to list all Docker images in our environment. Let’s refer to another tutorial for more basic Docker commands.To list all Docker images: docker images For example, docker images REPOSITORY TAG IMAGE ID CREATED SIZE alpine latest 4a415e366388 5 days ago 3.98 MB hello-world latest 48b5124b2768 7 weeks ago 1.84 kB busybox latest 7968321274dc 7 weeks ago 1.11 MB iron/node latest 9ca501065d18 10 months ago 18.6 MB To list all Docker images including intermediate images: docker images -a 1.2. Remove One or More Docker Images1.2.1. Using the d…

How to Get IP Address of a Docker Container

This quick tutorial is going to cover how to get IP address of a Docker container from host machine or inside a Docker container.1. Get ID or Name of a Docker ContainerWe’re going to review how to get ID or name of a Docker container first because they’re prerequisite to get IP address of the Docker container. You can refer to another tutorial for more basic Docker commands.To get ID or name of a Docker container, we can issue the following command from the host machine: docker ps By default, the command shows all running containers as the following: CONTAINER ID IMAGE CREATED STATUS PORTS NAMES 260f108e4271 wurstmeister/kafka 2 minutes ago Up 2 minutes tender_gates 4a432e03f0c3 wurstmeister/zookeeper 3 minutes ago Up 3 minutes 22/tcp naughty_mestorf We can show all containers by adding the -a option for the command: docker ps -a We can filter by using | operator: docker ps -a | grep kafka After getting the ID or name of the D…