I have installed docker on my host virtual machine. And now want to create a file using vi
.
But it's showing me an error:
bash: vi: command not found
2. For Ubuntu/Debian. The official Docker image of Ubuntu and Debian does not contain the vim package.
login into container with the following command:
docker exec -it <container> bash
Then , run the following command .
apt-get update apt-get install vim
The command to run depends on what base image you are using.
For Alpine, vi
is installed as part of the base OS. Installing vim
would be:
apk -U add vim
For Debian and Ubuntu:
apt-get update && apt-get install -y vim
For CentOS, vi
is usually installed with the base OS. For vim
:
yum install -y vim
This should only be done in early development. Once you get a working container, the changes to files should be made to your image or configs stored outside of your container. Update your Dockerfile and other files it uses to build a new image. This certainly shouldn't be done in production since changes inside the container are by design ephemeral and will be lost when the container is replaced.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With