When I use a normal terminal in linux, I can use the up arroy key to navigate between previous command that I executed. I need do the same in a container in docker.
Ex:
Login to the container work space with this command:
/usr/bin/winpty.exe docker-compose exec workspace bash
Then, In the workspace container I run something command like this:
composer self-update
And then I close the current session, The next time that I try to repeat the same steps whenever I'm logged in the container, the prompt history doesn't have any commands saved.
I use laradock in windows.
After that I searched more about this problem, I found this reports in git-hub
https://github.com/moby/moby/issues/13817
https://github.com/Maximus5/ConEmu/issues/183
Finally the problem for me was the client that I used (git-cli). I change to (Powershell) and it works perfectly. Putty it's too an alternative to connect to docker environment.
Related
I have a container with a python script that runs at startup, that I'm using to verify basic VM functionality.
while True:
print('Looping forever')
time.sleep(3)
pass
I have deployed this to a GCE VM instance with stdin buffer enabled.
The GCE instance is green-checkmarked.
I can connect to the VM using browser window ssh and see the container running.
I can docker attach to the active container.
What's not working:
I don't see any output from the script when I look at the VM logs in the Google Cloud console.
I don't see any output when attached to the active container. I can't use Ctrl+C or Ctrl+Z to exit back to shell.
I can docker run $image inside the ssh session, but I don't see any output and can't exit back to shell (same problem as with docker attach above).
If I close the browser ssh window and open a new browser ssh window, I can now see two containers running, the original one and the one that I launched in the previous ssh session using docker run.
I feel like there is something stupidly trivial that I've forgotten to set up.
===== EDIT =====
I found that even when I docker run locally, I don't see output and can't exit. I have to use kill in another terminal window to kill it.
When I run docker run -it $image in the VM's browser ssh terminal, I also see the output, which is good.
I think there's some behavior of docker attach that is working as intended, just not intuitive. I'd still like to achieve one of these goals:
Be able to see the output from the running container in the VM ssh session.
Be able to see the output from the running container in cloud logs.
Answering my own question for posterity: Need to set up cloud logging first
https://cloud.google.com/logging/docs/setup/python
I got the below issue when I try to start the container where I am running airflow:
"Incorrect remote log configuration. Please check the configuration of
option 'host' in "
That is happening after I change the remote_logging from False to True.
My container is not starting because of this and hence I don't get to come back to the previous configuration. Is there a way I can get come back to the previous version or fix it without needing to create a new environment?
If you have a container that won't keep running, but you want to start it for experimentation or modification, you can always overwrite the entrypoint config like this:
docker run -it --entrypoint sh <docker-image>
Once you have the container shell open, you can make your modifications and then start the process that the container would have normally started, e.g. Airflow.
I have Docker installed inside a Virtual Machine with Windows Server 2016.
I have a Linux Container from Python3 with NGINX server using --restart=always param, it runs fine while I am logged in, if I restart the VM, the container is no longer active, and it starts only if I log in.
Also if I logout, the container stops.
How can I make a container run as a service without login and keep it running on logout?
I've got a better answer from HERE
The summary is to build a Task and assign it to Task Scheduler to run on Windows start.
All the scripts should be run on powershell
Logon to the windows server/machine where you want the Docker services to start automatically.
Create a file called startDocker.ps1 at your location of choice and save the following script inside it:
start-service -Name com.docker.service
start C:\'Program Files'\Docker\Docker\'Docker Desktop.exe'
Verify that the location of Docker.exe is correct on your machine otherwise modify it in the script accordingly.
Create a file called registerTask.ps1 and save the following script inside it.
$trigger = New-ScheduledTaskTrigger -AtStartup
$action = New-ScheduledTaskAction -Execute "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -Argument "-File C:\PowershellScripts\startDocker.ps1"
$settings = New-ScheduledTaskSettingsSet -Compatibility Win8 -AllowStartIfOnBatteries
Register-ScheduledTask -Action $action -Trigger $trigger -TaskName "Start Docker on Start up" -Settings $settings -User "Your user" -Password "Your user password" -RunLevel Highest
This is needed so that this user has access to docker services
try
{
Add-LocalGroupMember -Group docker-users -Member "Your user" -ErrorAction Stop
}
catch [Microsoft.PowerShell.Commands.MemberExistsException] { }
Modify the script: You will have to change a couple of things in the scripts above according to your computer/server.
In the $action line, change the location of startdocker.ps1 script file to where you have placed this file.
In the Register-ScheduledTask line change the account user and password to an account user that needs Docker services to be started at the Windows start-up.
Execute registerTask.ps1
Open Windows Powershell as Administrator and set the current directory to where you have placed registerTask.ps1. For example
cd C:\PewershellScripts\
Next execute this script as follows
.\PowershellScripts\
Since I went through quite a lot of pain in order to make this work, here is a solution that worked for me for running a linux container using docker desktop on a windows 10 VM.
First, read this page to understand a method for running a python script as a windows service.
Then run your container using powershell and give it a name e.g
docker run --name app your_container
In the script you run as a service, e.g the main method of your winservice class, use subprocess.call(['powershell.exe', 'path/to/docker desktop.exe]) to start docker desktop in the service. Then wait for docker to start. I did this by using the docker SDK:
client = docker.from_env()
started = False
while not started:
try:
info = client.info()
started = True
except:
time.sleep(1)
When client has started, run your app with subprocess again
subprocess.call(['powershell.exe', 'docker start -interactive app'])
Finally ssh into your container to keep the service and container alive
subprocess.check_call(['powershell.exe', 'docker exec -ti app /bin/bash'])
Now install the service using python service.py install
Now you need to create a service account on the VM that has local admin rights. Go to Services in windows, and find your service in the list of services. Right click -> properties -> Log On and enter the service account details under "This account". Finally, under general, select automatic(delayed) start and start the service.
Probably not the most 'by the book' method, but it worked for me.
what version of docker did you install exactly / in detail?
The procedure to get docker running on a server is very different than for desktops!
It's purely script based as described in detail in the MS virtualization docs
The executable name of the windows-server docker EE (enterprise) service is by the way indeed dockerd as in linux.
I am trying to get the Superset running on ubuntu server. I have referenced the steps from Superset page as below:
git clone https://github.com/apache/incubator-superset/
cd incubator-superset/contrib/docker
# prefix with SUPERSET_LOAD_EXAMPLES=yes to load examples:
docker-compose run --rm superset ./docker-init.sh
# you can run this command everytime you need to start superset now:
docker-compose up
I have fixed the initial issues around right version of docker-compose and postgress address bind issue on port 5432. So after fixing those my docker compose run command
docker-compose run --rm superset ./docker-init.sh
works fine and it asks me to set up a user name and password.
Finally to get the container running I run the final command
docker-compose up.
On my mac, it would run redis, postrgre container and then give me a localhost:8088 for me to get access to Superset UI with login info.
However on Ubuntu, when I run that, I first get this:
So looks it is running redis and postgres containers fine.
But then it is giving me Permission denied errors to create some mkdir directory.
Pls note I am running it as root user.
Also, my docker compose version is fine with 1.23.2 and my docker along with docker-compose is installed under
/usr/bin/docker and not /usr/local/bin/docker.
But I think that shouldn't be an issue.
Any help where it is going wrong and how can I fix it?
Thanks
Edit:
Ok I looked at the same issue mentioned on Github. And used a suggestion of using it only for Production and not development in docker-compose.yml file.
It seems to not throw the same error now when I do
docker-compose up.
However when I open localhost:8088 it does not connect to the UI.
try this:
mkdir ../../assets
chmod -R 777 ../../superset/assets/
as set in docker-compose.yml#L64, it is using ../../superset as volume when in develop. However the container does not have any permission in the host so the solution is to make a directory by yourself and grant the necessary permissions on to it.
I am trying to run Tomcat in a Docker container with limited success. After I tried various things, I wanted to "reset" without completely deleting everything. I did stop and remove the virtual machine from the Virtualbox console. I then tried docker-machine create and docker-machine restart. My question is, if things reach a state in which the application appears to be hanging, what is the best procedure for starting from scratch that does not involve, for example, actually rebuilding the Docker container?
EDIT: All I am now asking is, given that "docker version" returns Client information but when it reaches the Server information I get the "An error occurred trying to connect" message, is what now needs to be done? What is it not connecting to? I tried with apparent success "docker-machine restart" but got no further with "docker version" after that.
First, don't delete the boot2docker VM itself (created by docker-machine)
If you want to reset, you might have to delete the container and image (quickly rebuilt with a docker build). But you can stay in the same docker-based boot2docker VM. No need for deletion.
Retrying a docker container session simply involve killing/removing the current container, and doing a new docker run.
Then, don't forget check what is not working: does a docker ps -a shows your container running? Can you access Tomcat from the boot2docker Linux host? From your actual OS host?
Based on that diagnostic and the exact content of your Dockerfile, you will be able to debug the issue.
The main issue might come from the fact docker command are executed from outside the VM.
That works only if the commands from docker-machine env <machine-name> are set.
See docker-machine env:
For cmd.exe:
$ docker-machine.exe env --shell cmd dev
set DOCKER_TLS_VERIFY=1
set DOCKER_HOST=tcp://192.168.99.101:2376
set DOCKER_CERT_PATH=C:\Users\captain\.docker\machine\machines\dev
set DOCKER_MACHINE_NAME=dev
# Run this command to configure your shell: copy and paste the above values into your command prompt.
(replace "dev" by the name of your docker machine here, probably "default")
But it is also perfectly fine to make all docker command from within the VM. No "env" to set.
Everything is on the VM (images, Dockerfile which can be on the Windows host as well, as long as it is under C:\Users\<yourLogin>, since that folder is automatically mounted as /c/Users/<yourLogin>)