How do I edit a file after I shell to a Docker container?

后端 未结 16 1767
你的背包
你的背包 2020-11-29 14:22

I successfully shelled to a Docker container using:

docker exec -i -t 69f1711a205e bash

Now I need to edit file and I don\'t have any edito

16条回答
  •  有刺的猬
    2020-11-29 15:04

    As in the comments, there's no default editor set - strange - the $EDITOR environment variable is empty. You can log in into a container with:

    docker exec -it  bash
    

    And run:

    apt-get update
    apt-get install vim
    

    Or use the following Dockerfile:

    FROM  confluent/postgres-bw:0.1
    
    RUN ["apt-get", "update"]
    RUN ["apt-get", "install", "-y", "vim"]
    

    Docker images are delivered trimmed to the bare minimum - so no editor is installed with the shipped container. That's why there's a need to install it manually.

    EDIT

    I also encourage you read my post about the topic.

提交回复
热议问题