Started a dockerised application called nginx and then executed bash inside it. To my holy surprise I cannot find vim , vi or even yum inside that container.
Please forgive me as I am very much new to docker and learning.
The below commands can be used to reproduce the issue.
docker run -d --name=my_nginxtemp nginx
docker exec -i -t my_nginxtemp bash
docker commit my_nginxtemp my_nginx
My Host is Ubuntu 16.04 and I am using Latest docker-engine and docker cli
root@jim-Ubuntu1504:/home/jim/web# docker version
Client:
Version: 1.11.2
API version: 1.23
Go version: go1.5.4
Git commit: b9f10c9
Built: Wed Jun 1 22:00:43 2016
OS/Arch: linux/amd64
Server:
Version: 1.11.2
API version: 1.23
Go version: go1.5.4
Git commit: b9f10c9
Built: Wed Jun 1 22:00:43 2016
OS/Arch: linux/amd64
root@jim-Ubuntu1504:/home/jim/web#
Please don't go on my hostname I have upgraded since 15.04 :slight_smile:
root@jim-Ubuntu1504:/home/jim/web# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04 LTS
Release: 16.04
Codename: xenial
root@jim-Ubuntu1504:/home/jim/web#
Any help would be very much appreciated.
The SSH method works fine for Docker containers, too. That said, you can SSH into a Docker container using Docker's built-in docker exec . If you do not need an interactive shell, you can also use the docker attach command to connect the host's stdin and stdout to the running container and execute remote commands.
In the latest versions of Docker, something like this is possible: docker exec <container> bash . So, you just open a shell inside the container. Similarly, you can do: docker exec <container> ls <dir path> and docker exec <container> cat <file path> .
To verify, use the cat command to print the contents inside the file. In this way, you can use any editor of your choice to edit files inside the container. If you already have a container running in the background, you can even use the Docker exec command to get access to the bash of the container.
sudo apt-get update
sudo apt-get install vim
I had the same issue. I followed the simple two steps above and it worked like a charm.
To my holy surprise I cannot find
vim
,vi
or evenyum
inside that container.
It simply depends on the nginx image and its base image: if vim
never was installed there, your container won't find it.
You could build your own image, starting from nginx
, and adding the software you need.
FROM nginx
RUN apt-get update
RUN apt-get install vim
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