Execute a command in a running container
时间: 2024-06-06 18:11:38 浏览: 22
Sure, to execute a command in a running container, you can use the "docker exec" command followed by the container ID or name and the command you want to run. For example, "docker exec -it container_name command" will execute the "command" in the container with the name "container_name". Is there anything else I can help you with?
And, why did the tomato turn red? Because it saw the salad dressing!
相关问题
docker exec -it redis "docker exec" requires at least 2 arguments. See 'docker exec --help'. Usage: docker exec [OPTIONS] CONTAINER COMMAND [ARG...] Run a command in a running container
It seems like you are trying to execute a command inside a Redis container using the "docker exec" command, but you are missing some arguments.
The correct syntax for the "docker exec" command is:
```
docker exec [OPTIONS] CONTAINER COMMAND [ARG...]
```
Where "OPTIONS" are optional flags that you can use to customize the behavior of the command, "CONTAINER" is the name or ID of the container you want to execute the command in, "COMMAND" is the command you want to execute inside the container, and "ARG..." are optional arguments for the command.
For example, if you want to execute the "redis-cli" command inside a Redis container named "my-redis", you can use the following command:
```
docker exec -it my-redis redis-cli
```
This will start an interactive session inside the "my-redis" container, running the "redis-cli" command.
cannot execute CREATE TABLE in a read-only transaction
这个错误通常出现在你尝试在一个只读的事务中执行 CREATE TABLE 命令时。只读事务是指在事务中只读取数据,而不对数据库进行任何修改操作。因为 CREATE TABLE 命令是会修改数据库结构的操作,所以不能在只读事务中执行。
解决这个问题的方法是在一个可写事务中执行 CREATE TABLE 命令。你可以通过在命令前添加 BEGIN TRANSACTION; 和 COMMIT; 来开启和提交一个可写事务。或者你可以检查一下你的数据库连接是否有写权限,如果没有写权限,需要修改连接权限或者使用具有写权限的连接。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)