Using '*' in docker exec command
If you want a shell inside the container to expand your glob, you need to... well... actually run a shell inside the container. The one outside the container can't see files inside the container (of course), so it passes ls
the literal pattern, not a list of files in the directory as you intend.
Thus:
docker exec -t t1 sh -c "ls /tmp/sth/*"
...note that I'd usually use single-quotes for the command, but since your host is Windows, using double quotes since they're more likely to work from cmd.exe
.
Running docker exec command with a shell string and parameters in bash script
You have to use double quotes to interpolate variables. Single quotes won't interpolate anything, but double quotes will.
docker exec $container sh -c "rm -rf /path/to/directory/${database}-${currdate}-*/"
From Bash manual:
3.1.2.2 Single Quotes
Enclosing characters in single quotes ('
) preserves the literal value of each character within the quotes. A single quote may not occur between single quotes, even when preceded by a backslash.
3.1.2.3 Double Quotes
Enclosing characters in double quotes (
"
) preserves the literal value of all characters within the quotes, with the exception of$
,`
,\
, and, when history expansion is enabled,!
. The characters$
and`
retain their special meaning within double quotes (see Shell Expansions). The backslash retains its special meaning only when followed by one of the following characters:$
,`
,"
,\
, or newline. Within double quotes, backslashes that are followed by one of these characters are removed. Backslashes preceding characters without a special meaning are left unmodified. A double quote may be quoted within double quotes by preceding it with a backslash. If enabled, history expansion will be performed unless an!
appearing in double quotes is escaped using a backslash. The backslash preceding the!
is not removed.
The special parameters *
and @
have special meaning when in double quotes (see Shell Parameter Expansion).
Build and run Dockerfile with one command
No, there is no single command. But if you tag your image as you build it, it will be easier to run:
docker build -t foo . && docker run -it foo
Using docker exec to run ros2 commands
The reason for this problem is that your ROS installation is not sourced.
Probably there is some issue with your bashrc file. Your local bashrc file does not work when calling a command within a docker container.
You can try to source your installation within the docker container fist and the run the desired command.
sudo docker exec my_docker /bin/bash -c ". /opt/ros/humble/setup.bash && ros2 node list"
How to handle prompt in Docker Exec
You can try setting the -i
flag on the docker command and piping a 'y' into it, like this
echo y | docker exec -i --user www-data nextcloud_docker php /var/www/html/occ db:convert-filecache-bigint
or you can run the command fully interactively with the -it
flags like this
docker exec -it --user www-data nextcloud_docker php /var/www/html/occ db:convert-filecache-bigint
How can I install packages using pip according to the requirements.txt file from a local directory?
This works for me:
$ pip install -r requirements.txt --no-index --find-links file:///tmp/packages
--no-index
- Ignore package index (only looking at --find-links
URLs instead).
-f, --find-links <URL>
- If a URL or path to an HTML file, then parse for links to archives.
If a local path or file://
URL that's a directory, then look for archives in the directory listing.
Docker exec command
Based on the information provided, docker is installed on a kernel version that's too old to run docker and doesnt have all feature required to safely run docker.
Docker requires kernel 3.10 as a minimum (preferably newer), and always make sure your kernel is up-to-date to minimize security risks.
Although Debian wheezy is still supported, if possible, I'd recommend to upgrade to a newer release (Jessie).
Related Topics
.Htaccess Redirect Index.PHP to /
How to Use Awk to Test If a Column Value Is in Another File
Environment Variables in Docker When Exec Docker Run
What Is The Correct Way to Define a Netfilter Hook Function
How to Properly Debug a Bash Script
On Building Docker Image Level=Error Msg="Can't Close Tar Writer: Io: Read/Write on Closed Pipe"
How to Write Kernel Space Memory (Physical Address) to a File Using O_Direct
Where Is Default Installation Directory for Mongodb
Dependency Failure While Installing Libboost-All-Dev on Ubuntu Core 14.04
Core Dump of Multithreaded Application Shows Only One Thread
Programmatically Disable Hardware Prefetching on Amd Systems
How to Use Linux Hugetlbfs for Shared Memory Maps of Files
Find Based Filename Autocomplete in Bash Script
List of Files Modified 1 Hour Before
In Shell, Split a Portion of a String with Dot as Delimiter
How to Redirect Entire Output of Spark-Submit to a File
Window Placement: Winsplit Revolution -Like Application for Linux (Kde)