23

Docker-toolbox is installed on the windows machine. I go into the container, for example: docker exec -it web / bin / sh I can enter commands there.

How to access the history of input commands inside a container? In all consoles, this is done using the up arrow key, here when you press this key, ^ [[A.

How to look at the history or at least call the previous command?

sveta600
  • 439
  • 4
  • 8

2 Answers2

16

As @DavidMaze pointed out, regular shell located in /bin/sh doesn't have the history feature unlike bash located (simply put) in /bin/bash

related threads can be found here and here, and a more detailed explanation about the difference between the two can be found here

Usage:

when starting fresh container:

docker run -it <imagename:tag> /bin/bash
docker run -it --entrypoint /bin/bash imagename:tag

when connecting to existing container:

docker exec -it <containerid or containername> /bin/bash
Noam Yizraeli
  • 4,446
  • 18
  • 35
11

The easier way is to type the command "bash" and then you'll be in bash with previous commands history.

L01C
  • 578
  • 1
  • 8
  • 25
  • You made my day! This solution is easy and worked like a charm! You have my million thanks! – Exis Mar 01 '23 at 04:05