简体   繁体   中英

how to access a path of a container from `docker-machine `

how to access a path of a container from docker-machine ? I have the ip docker-machine and I want to connect via remote in a docker image, eg:

when I connect to ssh docker@5.5.5.5 , all file are docker-machine, but I wat to conect a docker image via ssh.

whe I use this comman docker exec -u 0 -it test bash all files from the imagen are ok, but I want to access with ssh using docker-machine .

How can I do it?

This is tricky as Docker is designed to run a single process in foreground and containers dies when the process completed. This means Docker containers don't run anything additional other than what you define in the Dockerfile or docker-compose.yml .

What you can try is using docker-compose.yml file, expose the port 22 to outside world (also can be done through command line with Dockerfile ). This is NOT guaranteed to work as this require the image to run an SSH daemon and most cases it runs one process.

If you're looking to persist files that are used by containers, such as when a container is re-deployed it starts where it left off, you can mount a folder from host machine to the container as a volume.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM