How to fix docker containers that cannot be started

Source: Internet
Author: User
Tags docker cp docker run
How to fix docker containers that cannot be started

Background:

On the test server, an elasticsearch service cluster is built using docker. Because the plug-in for Chinese Word Segmentation needs to be installed for es, the installation cannot be started due to a problem. Because it is used for testing and development and does not mount data volumes for containers, after the containers are closed, there will be no related directories on the host machine. The directory structure of the Plugins directory causes the es service to fail to start if it cannot find the relevant file.

Solution: run the CP command to copy the entire plugins directory to the host, and then run the CP command back to the container:

# Send the Plugins directory CP to the host [[email protected] ~] # Docker CP ES1:/usr/share/elasticsearch/plugins... modify the directory structure... [[email protected] ~] # Docker CP./plugins/ES1:/usr/share/elasticsearch/# cp return to the container [[email protected] ~] # Docker start ES1 # Start the container

Another solution is to create an image, submit the container with docker commit to a new image, and then run a new container with docker run-it based on the new image to change (fix) configuration file. Submit a new image through the new container, and then restart the container based on the new image (same as the original container ). This method is feasible, but the problem is that there are many steps and a new image is submitted, which adds complexity to subsequent maintenance.

The procedure is as follows:

# Submit the container to be repaired as an image [[email protected] ~] # Docker commit <container_id> <image_name>: <tag> [email protected] ~] # Docker Rm <container_id> # delete a container that cannot be started. It cannot be used anyway. # view the newly created image [[email protected] ~] # Docker imagesrepository tag image ID created SIZEold-es3 first bf1fdb9b3a2d 54 minutes ago 550 MBold-es2 first 4e1a92871782 55 minutes ago 550 MBold-es1 first ready 55 minutes ago 551 MB # use this new image to create a container and enter the container, fix the configuration file [[email protected] ~] # Docker run-it -- name fix-es1 old-es1: First/bin/bash # resubmit the image [[email protected] ~] # Docker commit <container_id> <image_name>: <tag> # create a repaired container [email protected] ~] # Docker run-d -- name ES1-P 9200: 9200-P 9300: 9300 ok-es1: first

How to fix docker containers that cannot be started

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.