Quantcast
Channel: How do I edit a file after I shell to a Docker container? - Stack Overflow
Browsing all 27 articles
Browse latest View live

Answer by simhumileco for How do I edit a file after I shell to a Docker...

For common edit operations I prefer to install vi (vim-tiny), which uses only 1491 kB or nano which uses 1707 kB. In other hand vim uses 28.9 MB. We have to remember that in order for apt-get install...

View Article



Answer by Aidar Gatin for How do I edit a file after I shell to a Docker...

If you use Windows container and you want change any file, you can get and use Vim in Powershell console easily. To shelled to the Windows Docker container with PowerShell: docker exec -it <name>...

View Article

Answer by Dos for How do I edit a file after I shell to a Docker container?

After you shelled to the Docker container, just type: apt-get update apt-get install nano

View Article

Answer by Shihe Zhang for How do I edit a file after I shell to a Docker...

See Stack Overflow question sed edit file in place It would be a good option here, if: To modify a large file, it's impossible to use cat. Install Vim is not allowed or takes too long. My situation is...

View Article

Answer by Saubhagya Srivastava for How do I edit a file after I shell to a...

An easy way to edit a few lines would be: echo "deb http://deb.debian.org/debian stretch main" > sources.list

View Article


Answer by David Dehghan for How do I edit a file after I shell to a Docker...

You can just edit your file on host and quickly copy it into and run it inside the container. Here is my one-line shortcut to copy and run a Python file: docker cp main.py my-container:/data/scripts/ ;...

View Article

Answer by bbeecher for How do I edit a file after I shell to a Docker container?

It is kind of screwy, but in a pinch you can use sed or awk to make small edits or remove text. Be careful with your regex targets of course and be aware that you're likely root on your container and...

View Article

Answer by Matthew for How do I edit a file after I shell to a Docker container?

To keep your Docker images small, don't install unnecessary editors. You can edit the files over SSH from the Docker host to the container: vim scp://remoteuser@containerip//path/to/document

View Article


Answer by yan for How do I edit a file after I shell to a Docker container?

Sometime you must first run the container with root: docker exec -ti --user root <container-id> /bin/bash Then in the container, to install Vim or something else: apt-get install vim

View Article


Answer by meijsermans for How do I edit a file after I shell to a Docker...

You can use cat if it's installed, which will most likely be the case if it's not a bare/raw container. It works in a pinch, and ok when copy+pasting to a proper editor locally. cat > file # 1. type...

View Article

Answer by MaxiReglisse for How do I edit a file after I shell to a Docker...

You can also use a special container which will contain only the command you need: Vim. I chose python-vim. It assumes that the data you want to edit are in a data container built with the following...

View Article

Answer by hkong for How do I edit a file after I shell to a Docker container?

If you don't want to add an editor just to make a few small changes (e.g., change the Tomcat configuration), you can just use: docker cp <container>:/path/to/file.ext . which copies it to your...

View Article

Answer by ynux for How do I edit a file after I shell to a Docker container?

I use "docker run" (not "docker exec"), and I'm in a restricted zone where we cannot install an editor. But I have an editor on the Docker host. My workaround is: Bind mount a volume from the Docker...

View Article


Answer by Opal for How do I edit a file after I shell to a Docker container?

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 <container> bash And run: apt-get...

View Article

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

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 editors inside: root@69f1711a205e:/# nano bash: nano: command not...

View Article


Answer by xD3ath for How do I edit a file after I shell to a Docker container?

You can open existing file with cat filename.extension and copy all the existing text on clipboard. Then delete old file with rm filename.extension or rename old file with mv old-filename.extension...

View Article

Answer by dero for How do I edit a file after I shell to a Docker container?

You can use cat if installed, with the > caracter.Here is the manipulation :cat > file_to_edit#1 Write or Paste you text#2 don't forget to leave a blank line at the end of file#3 Ctrl + C to...

View Article


Answer by Victor Liu for How do I edit a file after I shell to a Docker...

I agree that @hkong's answer should be accepted, as it avoids adding additional packages to the container. However, I found that after pasting the modified file to the container, some of them tended to...

View Article

Answer by etemtezcan for How do I edit a file after I shell to a Docker...

If you can only shell into container with bin/sh (in case bin/bash doesn't work)and apt or apt-get doesn't work in the container, check whether apk is installed by entering apk in command prompt inside...

View Article

Answer by Dibya Darshan Khanal for How do I edit a file after I shell to a...

Make sure to update the container before trying to install the editor.apt-get updateapt-get install nano vi

View Article
Browsing all 27 articles
Browse latest View live




Latest Images