bash: line : docker: command not found - linux

I am using jenkins in a docker container and would like to start another instance, whenever I try to use docker command like
docker run -t -i ap/dashboard /bin/bash
I get this error:
bash: line 61: docker: command not found
How do I navigate to another container or solve this error?
I can clearly see that the vm creator was able to use the docker command by reading the /root/.ash_history
here are some details about the system:
[-] Specific release information:
3.3.1
NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.3.1
PRETTY_NAME="Alpine Linux v3.3"
HOME_URL="http://alpinelinux.org"
BUG_REPORT_URL="http://bugs.alpinelinux.org"
Hostname:
b51cdbb7eebd
ENVIRONMENTAL #######################################
Environment information:
JENKINS_VOL=/var/lib/jenkins
JAVA_VERSION_BUILD=17
HOSTNAME=b51cdbb7eebd
JAVA_VERSION_MAJOR=8
JENKINS_HOME=/opt/jenkins
NLSPATH=/usr/dt/lib/nls/msg/%L/%N.cat
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/java/jre/bin
JAVA_BASE=/usr/local/java
PWD=/
JAVA_HOME=/usr/local/java/jre
JAVA_PKG=server-jre
LANG=C.UTF-8
XFILESEARCHPATH=/usr/dt/app-defaults/%L/Dt
SHLVL=2
HOME=/root
PKG_URL=https://circle-artifacts.com/gh/andyshinn/alpine-pkg-glibc/6/artifacts/0/home/ubuntu/alpine-pkg-glibc/packages/x86_64
JENKINS_VERSION=1.637
JAVA_VERSION_MINOR=66
_=/usr/bin/env
[-] Available shells:
# valid login shells
/bin/sh
/bin/ash
/bin/bash
[+] We can read root's home directory!
total 76
drwx------ 5 root root 4.0K Aug 28 2018 .
drwxr-xr-x 1 root root 4.0K Nov 24 10:55 ..
-rw------- 1 root root 3.1K Aug 29 2018 .ash_history
-rw------- 1 root root 155 May 16 2016 .bash_history
drwxr-xr-x 2 root root 4.0K May 12 2016 .oracle_jre_usage
drwx------ 2 root root 4.0K Aug 28 2018 .ssh
-rwxr-xr-x 1 root root 46.0K Aug 28 2018 LinEnum.sh
drwxr-xr-x 3 root root 4.0K May 12 2016 dockerfiles
-rw-r--r-- 1 root root 0 Aug 28 2018 foo
Looks like we're in a Docker container:
10:net_prio:/docker/b51cdbb7eebd806431ee4120d9b3ae050dbefe4a835bf2063446724572e45e30
9:net_cls:/docker/b51cdbb7eebd806431ee4120d9b3ae050dbefe4a835bf2063446724572e45e30
8:freezer:/docker/b51cdbb7eebd806431ee4120d9b3ae050dbefe4a835bf2063446724572e45e30
7:devices:/docker/b51cdbb7eebd806431ee4120d9b3ae050dbefe4a835bf2063446724572e45e30
6:memory:/docker/b51cdbb7eebd806431ee4120d9b3ae050dbefe4a835bf2063446724572e45e30
5:blkio:/docker/b51cdbb7eebd806431ee4120d9b3ae050dbefe4a835bf2063446724572e45e30
4:cpuacct:/docker/b51cdbb7eebd806431ee4120d9b3ae050dbefe4a835bf2063446724572e45e30
3:cpu:/docker/b51cdbb7eebd806431ee4120d9b3ae050dbefe4a835bf2063446724572e45e30
2:cpuset:/docker/b51cdbb7eebd806431ee4120d9b3ae050dbefe4a835bf2063446724572e45e30
1:name=openrc:/docker
-rwxr-xr-x 1 root root 0 May 16 2016 /.dockerenv
[-] Anything juicy in the Dockerfile:
-rw-r--r-- 1 root root 617 May 12 2016 /root/dockerfiles/jenkins/Dockerfile
I tried many docker commands without hope
is it because that I'm already inside the container??

Try with docker run -t -i ap/dashboard /bin/ash.
Maybe your container does not use bash so you should try with /bin/sh which is a symcolic link to the default installed shell processor.

Related

Permission denied in "make qemu" in wtakuo/xv6-env docker image

I have an image from https://hub.docker.com/r/wtakuo/xv6-env. I pull it with docker pull wtakuo/xv6-env and run it with:
$ docker run -it --rm -v $(pwd):/home/xv6/xv6-riscv wtakuo/xv6-env
After container created and run image on its, I run make qemu but I get this error:
mkfs/mkfs fs.img README user/_cat user/_echo user/_forktest user/_grep user/_init user/_kill user/_ln user/_ls user/_mkdir user/_rm user/_sh user/_stressfs user/_usertests user/_grind user/_wc user/_zombie
fs.img: Permission denied
make: *** [Makefile:137: fs.img] Error 1
I don't know what should be do to fix it.
this is my directory content (with ll command):
drwxrwxr-x 8 root root 4096 Nov 1 16:30 .git/
-rw-rw-r-- 1 xv6 xv6 1174 Nov 1 16:27 LICENSE
-rw-rw-r-- 1 xv6 xv6 4709 Nov 1 16:27 Makefile
-rw-rw-r-- 1 root root 2305 Nov 1 16:24 README
-rw-rw-r-- 1 xv6 xv6 17 Nov 1 16:30 README.md
drwxrwxr-x 2 xv6 xv6 4096 Nov 4 17:57 kernel/
drwxrwxr-x 2 xv6 xv6 4096 Nov 4 17:57 mkfs/
drwxrwxr-x 2 xv6 xv6 4096 Nov 4 17:57 user/
I googled for this but not found effectively answer.
I tried
sudo chown -R user1:user1 *
but show this error: fs.img: Permission denied
For this problem, we must use from sudo command.
our user is xv6 and the password is also the same.
after use from it, we see this output:
xv6 kernel is booting
hart 1 starting
hart 2 starting
init: starting sh

Mkdir creates file instead of directory on windows network drive mounted as drvfs using Ubuntu/windows 10 under WSL

The command mkdir creates a file rather than a directory on a mounted network drive on a windows 10 system operating under the Windows sub-system for linux, using the Ubuntu app.
After installing the ubuntu app and putting the windows machine into developer mode I successfully mounted a remote network drive using the command:
sudo mount -t drvfs '\\networkdrive\sharename' /mnt/U
which successfully mounts the network drive at the mount point. I can see the files on the remote drive. However when looking at a directory on the remote machine and issuing the command
mkdir Source
a file called Source is created on the remote drive rather than a directory.
I tried this on two completely different laptops running windows 10, which I set up in exactly the same way and the same problem happens. The windows 10 machines are in developer mode and running the latest version of the ubuntu app. This is a pretty fundamental thing to have go wrong so I'm guessing it's a bug of some sort.
The snippet below is the terminal output which illustrates the problem.
username#~$ pwd
/home/username
username#~$ sudo mount -t drvfs '\\networkdrive.host\sharename\' /mnt/U
[sudo] password for username:
username#~$ cd /mnt/U/People/username/projects/Vesiform
username#Vesiform$ ls -al
total 0
drwxrwxrwx 0 root root 512 Mar 29 2018 .
drwxrwxrwx 0 root root 512 Mar 28 12:04 ..
drwxrwxrwx 0 root root 512 Mar 28 11:12 Builder
drwxrwxrwx 0 root root 512 Mar 28 11:42 Library
drwxrwxrwx 0 root root 512 Mar 28 11:42 NPack
drwxrwxrwx 0 root root 512 Mar 28 11:42 PDBProc
drwxrwxrwx 0 root root 512 Mar 28 11:55 Projects
drwxrwxrwx 0 root root 512 Mar 28 11:55 SpacePack
drwxrwxrwx 0 root root 512 Mar 28 11:55 Utilities
username#Vesiform$ mkdir Source
username#Vesiform$ ls -al
total 0
drwxrwxrwx 0 root root 512 Mar 29 2018 .
drwxrwxrwx 0 root root 512 Mar 28 12:04 ..
drwxrwxrwx 0 root root 512 Mar 28 11:12 Builder
drwxrwxrwx 0 root root 512 Mar 28 11:42 Library
drwxrwxrwx 0 root root 512 Mar 28 11:42 NPack
drwxrwxrwx 0 root root 512 Mar 28 11:42 PDBProc
drwxrwxrwx 0 root root 512 Mar 28 11:55 Projects
-rwxrwxrwx 1 root root 0 Mar 29 2018 Source
drwxrwxrwx 0 root root 512 Mar 28 11:55 SpacePack
drwxrwxrwx 0 root root 512 Mar 28 11:55 Utilities
username#Vesiform$ cd Source
-bash: cd: Source: Not a directory
username#Vesiform$

Create symbolic link fails in Docker for Windows, it's not supported yet?

I have a docker container running Ubuntu Server. I am running Docker for Windows and I have the following version of Docker and Docker Compose respectively installed:
> docker-compose -v
docker-compose version 1.11.2, build f963d76f
> docker -v
Docker version 17.03.1-ce-rc1, build 3476dbf
This is what I have tried so far without success:
// The dojo linked file exists so I've tried to update it as per this answer (http://stackoverflow.com/a/1951752/719427)
> docker exec -it dockeramp_webserver_1 ln -sf /var/www/html/externals/dojo /var/www/html/externals/public_html/js/dojo
ln: failed to create symbolic link '/var/www/html/externals/public_html/js/dojo': No such file or directory
// I have deleted the previous linked file and then I tried to create a new one
> docker exec -it dockeramp_webserver_1 ln -s /var/www/html/externals/dojo /var/www/html/externals/public_html/js/dojo
ln: failed to create symbolic link '/var/www/html/externals/public_html/js/dojo': No such file or directory
// removed the directory name from the link name
> docker exec -it dockeramp_webserver_1 ln -s /var/www/html/externals/dojo /var/www/html/externals/public_html/js
ln: failed to create symbolic link '/var/www/html/externals/public_html/js': No such file or directory
Because the error keep saying the directory doesn't exists then I've checked if the error is right or wrong:
> docker exec -u www-data -it dockeramp_webserver_1 ls -la /var/www/html/externals/dojo
total 80
drwxr-xr-x 2 root root 0 Mar 25 15:09 .
drwxr-xr-x 2 root root 4096 Mar 25 15:09 ..
drwxr-xr-x 2 root root 0 Mar 25 15:09 dijit
drwxr-xr-x 2 root root 0 Mar 25 15:09 dojo
drwxr-xr-x 2 root root 0 Mar 25 15:09 dojox
drwxr-xr-x 2 root root 0 Mar 25 15:09 mmi
-rwxr-xr-x 1 root root 74047 Mar 25 15:09 tundra.css
> docker exec -u www-data -it dockeramp_webserver_1 ls -la /var/www/html/public_html/js
total 24
drwxr-xr-x 2 root root 4096 Mar 26 14:40 .
drwxr-xr-x 2 root root 4096 Mar 25 15:11 ..
-rwxr-xr-x 1 root root 7123 Mar 25 15:09 jquery.PrintArea.js
-rwxr-xr-x 1 root root 6141 Mar 25 15:11 quoteit_delegate_search.js
They both exists so ... what I am missing here? It's not supported in Windows just yet? I have found the development team added something called mfsymlinks in a previous version than mine.
The command is telling you that /var/www/html/externals/public_html does not exist. You only showed that the /var/www/html/externals/dojo and /var/www/html/public_html/js folders exist. I believe this is a simple typo in your commands.

Changing Directory in Bash Script

I'm trying to run a bash script which should go in a specific directory.
The Problem is that the Script wont go in the newest Folder.
The Folder looks like:
root#raspberry ~/jdownloader/logs # ls -lha
total 104K
drwxr-xr-x 9 root root 4.0K Nov 30 11:52 .
drwxr-xr-x 14 root root 4.0K Nov 30 11:52 ..
drwxr-xr-x 2 root root 4.0K Nov 30 11:18 1479843940152_Tue, Nov 22, 2016 20.45 +0100
drwxr-xr-x 2 root root 4.0K Nov 30 11:21 1480501204839_Wed, Nov 30, 2016 11.20 +0100
drwxr-xr-x 2 root root 4.0K Nov 30 11:22 1480501242752_Wed, Nov 30, 2016 11.20 +0100
drwxr-xr-x 2 root root 4.0K Nov 30 11:30 1480501308071_Wed, Nov 30, 2016 11.21 +0100
drwxr-xr-x 2 root root 4.0K Nov 30 11:56 1480503116574_Wed, Nov 30, 2016 11.51 +0100
drwxr-xr-x 3 root root 12K Nov 23 11:25 extracting
drwxr-xr-x 2 root root 64K Nov 30 11:22 updatehistory
The Important Snippet from my Script is:
#!/bin/bash
declare dir=/var/log/scriptlog/jdstate
declare dir2=~/jdownloader/logs
NewFolder=`ls -rt1 ~/jdownloader/logs -I extracting -I updatehistory | tail -1 > /var/log/scriptlog/jdstate/newfolder.log`
OutputNewFolder=`head $dir/newfolder.log -n 1`
cd\ "\"$dir2/$OutputeNewFolder\""
When I try to run the script it shows me the error that it can't find the directory.
But when I copy/paste it, it will go to the Directory.
Any idea how it is possible to go to the directory?
For every one how is searching for an Answer:
this is my latest code snippet wich worked gladly for me
#!/bin/bash
declare dir=/var/log/scriptlog/jdstate
declare dir2=~/jdownloader/logs
NewFolder=`ls -rt1 ~/jdownloader/logs -I extracting -I updatehistory | tail -1 > /var/log/scriptlog/jdstate/newfolder.log`
OutputNewFolder=`head $dir/newfolder.log -n 1`
cd "$dir2/$OutputNewFolder"
I´m sure the can be improvements for the newest folder but htis works just finde for me

Touch command. permission denied

I was able to connect to my school server via SSH. I had an assignment in which I was supposed to use the touch command to create a new file. Yet it keeps returning permission denied. Others were able to do the same thing. Though why do I keep getting this error?
Below is what was the input from the terminal.
Last login: Tue Aug 23 09:16:18 on ttys000
Dominiks-Air:~ fsociety95$ ssh djaneka1#navajo.dtcc.edu
djaneka1#navajo.dtcc.edu's password:
Last login: Tue Aug 23 09:16:35 2016 from pool-72-94-210-193.phlapa.fios.verizon.net
Navajo is Linux shell server provided to staff, faculty, and students. The
operating system is RedHat Enterprise Linux 5.
Alpine, a Pine replacement, has been provided as a mail client. Run "pine"
at the command prompt.
This server also provides web space to users. Web pages can be stored in
the ~/www directory. This is also accessible by mapping a drive in Windows
to \navajo\homepage. The URL for your homepage is
http://user.dtcc.edu/~username/.
Your home directory is also accessible in Windows by mapping to
\navajo\.
If something appears broken or missing, please email path#dtcc.edu.
Could not chdir to home directory /u/d/j/djaneka1: No such file or directory
-bash-3.2$ touch today
touch: cannot touch `today': Permission denied
-bash-3.2$ pwd
/
-bash-3.2$ touch today
touch: cannot touch `today': Permission denied
-bash-3.2$
Edit: here is the result of ls -al
-bash-3.2$ ls -al
total 204
drwxr-xr-x 25 root root 4096 Aug 22 16:50 .
drwxr-xr-x 25 root root 4096 Aug 22 16:50 ..
-rw-r--r-- 1 root root 0 Aug 3 14:01 .autofsck
-rw-r--r-- 1 root root 0 Jan 30 2009 .autorelabel
-rw------- 1 root root 2050 Aug 3 14:00 .bash_history
drwxr-xr-x 2 root root 4096 May 4 04:14 bin
drwxr-xr-x 4 root root 3072 Aug 3 13:57 boot
drwxr-xr-x 11 root root 4060 Aug 3 14:02 dev
drwxr-xr-x 87 root root 12288 Aug 23 10:05 etc
drwxr-xr-x 3 root root 4096 Oct 1 2009 home
drwxr-xr-x 13 root root 12288 Jun 1 04:09 lib
drwx------ 2 root root 16384 Mar 24 2008 lost+found
drwxr-xr-x 3 root root 4096 Oct 1 2009 media
drwxr-xr-x 2 root root 0 Aug 3 14:02 misc
drwxr-xr-x 4 root root 4096 May 26 2012 mnt
drwxr-xr-x 2 root root 0 Aug 3 14:02 net
drwxr-xr-x 9 root root 4096 Jan 5 2009 nsr
drwxrwxr-x 3 root root 4096 Oct 12 2015 opt
dr-xr-xr-x 219 root root 0 Aug 3 14:01 proc
drwxr-x--- 12 root root 4096 Apr 22 10:06 root
drwxr-xr-x 2 root root 12288 Aug 4 04:02 sbin
drwxr-xr-x 2 root root 4096 Oct 1 2009 selinux
drwxr-xr-x 2 root root 4096 Oct 1 2009 srv
drwxr-xr-x 11 root root 0 Aug 3 14:01 sys
drwxrwxrwt 38 root root 4096 Aug 23 10:07 tmp
drwxr-xr-x 34 root root 4096 Jun 21 08:29 u
drwxr-xr-x 14 root root 4096 Apr 16 2010 usr
drwxr-xr-x 24 root root 4096 Apr 16 2010 var
-rw------- 1 root root 2865 Dec 16 2008 .viminfo
-bash-3.2$
EDIT:
Here is what I see after trying touch today in /home
So to try and create a new document in the root directory you need to be recognised as root. That means using the sudo command.
However for that you would need a password that you may not have. If you do perfect. But in any case I would not recommend adding files to the root directory.
Instead try the following:
cd home
touch today
This should work just fine and answer your question.
Still if you need/want to create today in your root directory try the following
sudo touch today
You will then be prompted for the root password that you can type (if you have it obviously)
In any case I suggest reading this which may be very helpful for you.
I wonder if this was ever truly answered.
If I was looking at it, I would try to see what the system thinks is the home directory of djaneka1, since it may have been setup partway and not completed, leaving stuff owned by root that should have been owned by djaneka1.
If you use the pwd command, and get back the "/" (root) directory there is something wrong with your setup.
The message: Could not chdir to home directory /u/d/j/djaneka1: No such file or directory
tells you it can't find your home directory.
-bash-3.2$ pwd
/
the command "pwd" revealing "/" is just an artifact of the system not being able to find your home directory.
To find what the system thinks is one's home directory,
one can search the file named '/etc/passwd' for one's login name.
I expect this is a possible result if you do that:
$ fgrep 'djaneka1' /etc/passwd
djaneka1:x:1505:1506::/u/d/j/djaneka1:/bin/bash
since it complained that it couldn't find that directory.
This needs to be fixed by someone who has more rights to the system, like root.
there is nothing djaneka1 can do a

Resources